i'm attaching a C pgm file here. I couldn't get the reason for output.
#include
and what is the output?
Ahh it prints "hi". Well, it's all about IEEE 754: http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17
u should use code editors like codepad and ideone
Specifically, in this example, you are comparing an object of type float to a double, which won't give you the expected false value.
To solve this, add the 'f' qualifier to the number 0.7, writing it as 0.7f
would it work if you defined double f =0.7?
you probably always want to use double since it's more precise than float
Right; double is safest if you aren't sure.
and when float is better to use?
Here's the long answer: http://docs.oracle.com/cd/E19422-01/819-3693/ncg_goldberg.html
Short answer: it might depend on certain arithmetic you're trying to do, compiler implementation, machine implementation, FPU etc.
thanks i got it
the safest is variant
Join our real-time social learning platform and learn together with your friends!