Share via


Double.NaN Field

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

Syntax

'Declaration
Public Const NaN As Double
public const double NaN

Remarks

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.

Examples

The following example illustrates the use of NaN:

Dim zero As Double = 0

' This condition will return false.
If (0 / zero) = Double.NaN Then
   outputBlock.Text &= "0 / 0 can be tested with Double.NaN." & vbCrLf
Else
   outputBlock.Text &= "0 / 0 cannot be tested with Double.NaN; use Double.IsNan() instead." & vbCrLf
End If
Double zero = 0;

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

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.