Your

`if`

conditions compares the single precision (`float`

) value with a double precision constant value. So the compiler converts the single precision value to double precision. The `else if`

condition compares with a single precision constant (which should always be true).The second value 0.5 can be represented exactly by floating point values. But this is not true for 0.1. When converting from single precision to double, the additional available bits will be cleared. But the double constant value 0.1 has some of these bits set. So the values are not binary identical.

You may use the converter at this page[^] to see the binary representation of single precision numbers and the corresponding double precision decimal.

1.) Comparing real numbers with "==" is problematic, you can find a lot of discussion about this in WWW

2.) In your case I think it is the mix between "double" (your right Hand side) and the "float" (left Hand side) for the Operator "==". To compare them an conversion is needed.