Why does NaN - NaN == 0.0 with the Intel C++ Compiler?

前端 未结 3 752
被撕碎了的回忆
被撕碎了的回忆 2021-01-29 18:22

It is well-known that NaNs propagate in arithmetic, but I couldn\'t find any demonstrations, so I wrote a small test:

#include 
#include 

        
3条回答
  •  生来不讨喜
    2021-01-29 19:01

    The default floating point handling in Intel C++ compiler is /fp:fast, which handles NaN's unsafely (which also results in NaN == NaN being true for example). Try specifying /fp:strict or /fp:precise and see if that helps.

提交回复
热议问题