Single.IsNaN Method

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

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

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

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Shared Function IsNaN ( _
    f As Single _
) As Boolean
[SecuritySafeCriticalAttribute]
public static bool IsNaN(
    float f
)

Parameters

  • f
    Type: System.Single
    A single-precision floating-point number.

Return Value

Type: System.Boolean
true if f evaluates to not a number (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.

Examples

The following code example demonstrates the IsNaN method.

' This will return true.
If Single.IsNaN(0 / zero) Then
   outputBlock.Text &= "Single.IsNan() can determine whether a value is not-a-number." & vbCrLf
End If
// This will return true.
if (Single.IsNaN(0 / zero))
{
   outputBlock.Text += "Single.IsNan() can determine whether a value is not-a-number." + "\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.