Why is double.NaN not equal to itself?

Solution 1:

If you are curious, this is what Double.IsNaN looks like:

public static bool IsNaN(double d)
{
    return (d != d);
}

Funky, huh?

Solution 2:

Use Double.IsNaN.

Solution 3:

bool isNaN = Double.IsNaN(yourNumber)