Possible Duplicate:
Floating point comparison
When I run the code below I get the following output:
Output : if
Why does this happen?
#include <stdio.h>
void main()
{
float a = 0.7;
if(a<0.7)
{
printf("if");
}
else
{
printf("Else");
}
}
Floating points are not stored in precise format. Most likely, your platform interprets
as
This is because of the internal representation of floating points on your platform. The link provided by Daniel should get you started.