int a; …; (a == a) fails?

后端 未结 9 975
执笔经年
执笔经年 2020-12-31 19:05

if we set float and double type to NaN then they are not equal to anything including themselves.
can such a thing happens for

9条回答
  •  庸人自扰
    2020-12-31 19:08

    NaN is the only value for a==a return false.

    And int doesn't support a NaN value. So no you can't have this situation with int.

    Another note, to check if a value is NaN you should use isnan() not a==a.


    On the same topic :

    • Negative NaN is not a NaN?

提交回复
热议问题