well i found the ans wer nd its not wht u all r saying .....floats or doubles can be compared using >= etc the ans lies in the internal representation of floats and doubles
float is represented using IEEE 754 single precision
double by IEEE 754 double precision so .7>.7f and so on.....thnx newayz
User Profile
Collapse
-
well ++ hs higher precedence thn + and therefore ur expression becomes
(++a) + (++a)
and the result is 23 ;
(11)+(12)Leave a comment:
-
comparing floating point numbers
i am posting codes and they give striking results can someone please explain why ???
[code=c]main()
{ float a=0.7 ;
if (a<0.7)
{ printf("c") ;
}
else
printf("c++") ;
}
[/code]OUTPUT is c
[code=c]main()
{ float a=0.7 ;
if (a<0.7f)
{ printf("c") ;
}
else
printf("c++")...Last edited by AdrianH; Jun 3 '07, 04:41 PM. Reason: Please use [code=c][/code] tags to improve readability
No activity results to display
Show More
Leave a comment: