Other answers hint at this, but this problem is caused by the fact that you are not adding "f" to your numbers.
Any number with a decimal point will be implicitly interpreted as a compiler as a double (that is, a 64-bit value with twice as much precision as a float). In your first line, you assign a double float, thereby losing accuracy (if you had warnings that you should have, you got a compiler warning).
In the second line, you compare the float with a double. The float will be doubled (correct me if I am wrong), so you have a less accurate version of 0.7 compared to a more accurate version of 0.7.
Solution: ALWAYS use "f" when working with floats, i.e.
float a = 0.7f; if (a < 0.7f);
EboMike
source share