Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Single.NaN Field

Represents not a number (NaN). This field is constant.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public const float NaN

The value of this constant is the result of dividing zero by zero.

This constant is returned when the result of an operation is undefined.

Use IsNaN to determine whether a value is not a number. It is not possible to determine whether a value is not a number by comparing it to another value equal to NaN.

The following code example demonstrates the NaN constant.


Single zero = 0;

// This condition will return false.
if ((0 / zero) == Single.NaN)
{
   outputBlock.Text += "0 / 0 can be tested with Single.NaN." + "\n";
}
else
{
   outputBlock.Text += "0 / 0 cannot be tested with Single.NaN; use Single.IsNan() instead." + "\n";
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2015 Microsoft