I observed some unclear behaviour in a C programm compiled with GCC. Could anymone explain why there is a difference in the following code
1a) The condition -1.30000007F >= ((float)-13 * 0.1F)
results in false.
1b) If I split up the condition into a variable assignment of the right side and compare it afterwards it results in true
float tmp_var = (float)-13 * 0.1F; // tmp_var = -1.30000007
-1.30000007F >= tmp_var // true
This happens with gcc (i686-posix-dwarf-rev1, Built by MinGW-W64 project) 12.2.0.
It is not happening with Greenhills compiler.
Additionally I saw as well
2a) (float)20999999 * 0.000001F < (float)21
is true
2b) while the following results in false
float tmp_var = (float)20999999 * 0.000001F; // 21.0
tmp_var < (float)21 // false
Based on the IEE-754 Floating Point Converter 20999999 is stored as 21000000.0 in float.
Even evaluating the expressions in the debugger (gdb) never result in the Xa) variants.