Floating point numbers are not exact. Specifically, your number is not necessarily compared against a float. The same code works as you expect if you use '0.7f
' instead of '0.7
' (on at least my compiler), but you should generally be comparing against a threshold, as the previous answer states.