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 >=
The Equality operator considers two NaN values to be unequal to one another. In general, Double operators cannot be used to compare Double.NaN with other Double values, although comparison methods (such as Equals and CompareTo) can. see below examples
Referenced from msdn
class Program
{
static void Main(string[] args)
{
Double i = Double.NaN;
while (!i.Equals(i)) //this would be result in false
//while(i != i) // this would result in true.
{
Console.WriteLine("Hello");
}
}
}
here is .net fiddle for the same.