0
In given code float value(c) and if value (c) matches then why is the output false?
4 ответов
+ 5
Krs 7 ,
put this line to your code just after variable c is declared and initialized. it will show more decimal places
...
float c=10.1;
printf("Double value: %.20f \n", c);
...
+ 3
The problem is "floating point precision". As floats/ doubles/ decimals cannot be represent with infinite precision, comparing them for equality fails.
+ 2
It may happen that they equal or it may happen that they don't – comparing floats isn't safe...
0
Lisa but if I give 10.00 as float value it gives true as output.