+ 4

In the code given below the output comes "True"... So plz. explain what is happening in the compiler...

float a = 0.7; if(0.7>a)printf("True"); else printf("False"); As it is treating 0.7 greater than 0.7 contained in a float variable...

28th Apr 2019, 4:09 PM
Sp Maurya
Sp Maurya - avatar
5 Respuestas
+ 7
In if statement you are comparing a double precision floating point to a single precision floating point. 0.7 (double)approximate value is greater than 0.7f
28th Apr 2019, 4:38 PM
kiRA
kiRA - avatar
28th Apr 2019, 4:41 PM
raget88
raget88 - avatar
+ 6
Testing equality is also tricky with floating point numbers.
30th Apr 2019, 11:10 AM
Sonic
Sonic - avatar
+ 2
Thanks... now i got it...
28th Apr 2019, 4:54 PM
Sp Maurya
Sp Maurya - avatar
+ 2
thankyou
30th Apr 2019, 3:15 AM
Arshi khan