Double.IsNaN(Double) 方法

定义

返回一个值,该值指示指定的值是否不为数字 (NaN)。

public:
 static bool IsNaN(double d);
public:
 static bool IsNaN(double d) = System::Numerics::INumberBase<double>::IsNaN;
public static bool IsNaN (double d);
static member IsNaN : double -> bool
Public Shared Function IsNaN (d As Double) As Boolean

参数

d
Double

一个双精度浮点数。

返回

如果 d 的计算结果为 NaN,则为 true;否则为 false

实现

示例

以下代码示例演示了 的用法 IsNaN

// This will return true.
if ( Double::IsNaN( 0 / zero ) )
{
   Console::WriteLine( "Double::IsNan() can determine whether a value is not-a-number." );
}
// This will return true.
if (Double.IsNaN(0 / zero))
   Console.WriteLine("Double.IsNan() can determine whether a value is not-a-number.");
// This will return true.
if Double.IsNaN(0. / zero) then
    printfn "Double.IsNan() can determine whether a value is not-a-number."
' 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

注解

浮点运算返回 NaN 以指示操作的结果未定义。 例如,将 0.0 除以 0.0 会导致 。NaN

注意

IsNaNfalse如果值为 或 NegativeInfinityPositiveInfinityDouble返回 。 若要测试这些值,请使用 IsInfinityIsPositiveInfinityIsNegativeInfinity 方法。

适用于

另请参阅