Export (0) Print
Expand All

Double.IsNaN Method

Returns a value indicating whether the specified number evaluates to a value that is not a number (NaN).

[Visual Basic]
Public Shared Function IsNaN( _
   ByVal d As Double _
) As Boolean
[C#]
public static bool IsNaN(
 double d
);
[C++]
public: static bool IsNaN(
 double d
);
[JScript]
public static function IsNaN(
   d : double
) : Boolean;

Parameters

d
A double-precision floating point number.

Return Value

true if d evaluates to NaN; otherwise, false.

Remarks

Floating-point operations return NaN to signal that that result of the operation is undefined. For example, dividing 0.0 by 0.0 results in NaN.

Example

[Visual Basic, C#, C++] The following code sample illustrates the use of IsNaN:

[Visual Basic] 
' This will return true.
If Double.IsNaN(0 / zero) Then
    Console.WriteLine("Double.IsNan() can determine whether a value is not-a-number.")
End If

[C#] 
// This will return true.
if (Double.IsNaN(0 / zero)) 
{
    Console.WriteLine("Double.IsNan() can determine whether a value is not-a-number.");
}

[C++] 
// This will return true.
if (Double::IsNaN(0 / zero)) {
   Console::WriteLine(S"Double::IsNan() can determine whether a value is not-a-number.");
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Double Structure | Double Members | System Namespace | NaN

Show:
© 2014 Microsoft