When taking y value as 0 in i1,it gives y1 as true.(0==0).When taking y value as 1 in i1,1 mod 2====>1/2=quotient 0.5 and reminder 0.that way I had taken.(calculator return quotient value 0.5.but compiler return quotient value 0.0 and remainder 0.).

I know that mod operator will give remainder part only.But when I take 1%2 working,I always take 0 as the remainder and 0.5 as the quotient.How comw the 1%2 value is quotient 0.0 and remainder 0?

. . . because you are using integer division, which loses its remainder.does not produce a double result. It is integer division which produces an integer result and it is then cast to a double.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40988

28

posted

0

Posted by Rusty Shackleford

Because they are integer values, not floating point values.