A define problem

Kevin D. Quitt kdq at demott.com
Thu Jan 10 06:43:03 AEST 1991


In article <4613 at sactoh0.SAC.CA.US> jak at sactoh0.SAC.CA.US (Jay A. Konigsberg) writes:
>
>Look at what is being passed to "half()".
>
>i=5
>half(i-5) or half(5-5) or half(0)
>
>which becomes: (0)/2 - which is 0.
>
>It looks like it should be:
>
>printf( "i/2 = %d\n",half(i));
>
>which produces 2, not 3 anyway. If you want to round up, you should
>define the variables as a float, add .5 and cast to (int).


    or half(i+1)


-- 
 _
Kevin D. Quitt         demott!kdq   kdq at demott.com
DeMott Electronics Co. 14707 Keswick St.   Van Nuys, CA 91405-1266
VOICE (818) 988-4975   FAX (818) 997-1190  MODEM (818) 997-4496 PEP last



More information about the Comp.lang.c mailing list