GCC problem with raw double type comparisons

前端 未结 3 1480
孤独总比滥情好
孤独总比滥情好 2021-01-05 03:54

I have the following bit of code, however when compiling it with GCC 4.4 with various optimization flags I get some unexpected results when its run.

#include         


        
3条回答
  •  情深已故
    2021-01-05 04:29

    The width of the floating point registers in x86 is different from the width of the double in RAM. Therefore comparisons may succeed or fail depending entirely on how the compiler decides to optimize the loads of floating point values.

提交回复
热议问题