0.1
cannot be represented exactly in binary . 0.1
in binary would be 0.0r0011r
which is recurring so internally it is rounded off which is not exact value. That is why it returns false. But if you try with number like 0.5 which is 0.1
in binary or 0.250 or 0.125 whichever can be perfectly represented it would return true. Also read http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html . Better to use double
for more accurate results.