Why is double.NaN not equal to itself?

后端 未结 11 1300
心在旅途
心在旅途 2020-11-27 17:42

Can someone explain this to me? In C# double.NaN is not equal to double.NaN

bool huh = double.NaN == double.NaN; // huh = false
bool huh2 = double.NaN >=          


        
11条回答
  •  悲&欢浪女
    2020-11-27 18:11

    Use Double.IsNan() to test for equality here. The reason is that NaN is not a number.

提交回复
热议问题