difference between float and double


main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}

what is the output of the above program and please explain how
A double is a double precision floating point number. It has more memory and allows for a larger mantissa.

http://www.cplusplus.com/doc/tutorial/variables/

If you're seeing "I hate U" as the output of your program it is due to comparing floats/doubles. They're not likely to be exactly equal.

http://floating-point-gui.de/errors/comparison/

i compiled this code and got the answer as "i hate you".

Thank you for your reply iHutch105
Topic archived. No new replies allowed.