In general, comparing equality with floats is a dangerous business (which is effective, what do you do when you compare directly at the border>), remember that in decimal some fractions (for example, 1/3) cannot be accurately expressed, the same can be said about binary,
0.5= 0.1 will be the same in float or double.
0.7=0.10110011001100 etc. forever, 0.7 cannot be represented exactly in binary, you get rounding errors and can (very much) differ between float and double
Note that between floats and doubles, you cut off a different number of decimal places, hence your inconsistent results.
Richard Tingle Apr 05 '13 at 13:44 2013-04-05 13:44
source share