0.1 cannot be represented exactly in floating point:
printf("%.16f\n", 0.1f);
displayed:
0.1000000014901161
So it nwill never be exactly the same 1.
As @sirlak notes in the comments below, it is almost never worth checking floating point variables for equality like this.
source
share