I stumbled upon .NET's definition of [`double.NaN`](http://msdn.microsoft.com/en-us/library/system.double.nan.aspx) in code:

```
public const double NaN = (double)0.0 / (double)0.0;

```

This is done similarly in `PositiveInfinity` and `NegativeInfinity`.

[`double.IsNaN`](http://msdn.microsoft.com/en-us/library/system.double.isnan.aspx) (with removing a few #pragmas and comments) is defined as:

```
[Pure] 
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static bool IsNaN(double d) 
{
    if (d != d)
    { 
        return true; 
    }
    else 
    {
        return false;
    }
}

```

This is very counter-intuitive to me.

Why is NaN defined as division by zero? How is `0.0 / 0.0` represented "behind the scenes"? How can division by 0 be possible in `double`, and why does `NaN != NaN`?