Comparing Same Float Values In C
strange output in comparison of float with float literal
Float addition promoted to double?
I read the above l
As you have read the links regarding problems with floating point types and comparisons, you are probably expecting that 0.5 is rounded during conversion and hence the comparison should fail. But 0.5 is a power of 2 and can be represented perfectly without any rounding in a float or double type variable. Therefore the comparison results in TRUE.
After your edited your question: Yes, if you took 0.1 or one of the other values you mention, you should run into the else part.