I came across this while debugging some unit tests that compared a returned single array against the expected results.
System.Single.NaN == System.Single.Nan;
The unit test was expecting true, but this evaluates to false. Why does this evaluate to false when the other static methods of single return true? Is NaN not a constant value ?
System.Single.MaxValue == System.Single.MaxValue;
System.Single.Epsilon == System.Single.Epsilon;
null == null;
http://msdn.microsoft.com/en-us/library/system.single.nan.aspx states: “Two NaN values are considered unequal to one another.” but this question is out of curiosity as to why this is so more than anything else.
Because the IEEE 754 standard (the one used for
floatanddouble) says so.To quote the wiki
(note that .NET doesn’t support the signaling NaN, and probably treats it as non-signaling)