How to compare two NAN values in C++

前端 未结 3 1546
离开以前
离开以前 2020-12-18 23:57

I have an application in which a code area produces NAN values. I have to compare the values for equality and based on that execute the rest of the code.How to compare two N

3条回答
  •  时光取名叫无心
    2020-12-19 00:35

    Any given NaN is not equal to anything, it will never be equal to any other NaN, so comparing them against each other is a futile exercise.

    From GNU docs:

    NaN is unordered: it is not equal to, greater than, or less than anything, including itself. x == x is false if the value of x is NaN. source

提交回复
热议问题