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

一個雙精度浮點數。

傳回

trued評估為NaN;否則,。 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) 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

Note

IsNaN若值falseDoublePositiveInfinity,則返回NegativeInfinity。 要測試這些值,請使用 IsInfinityIsPositiveInfinityIsNegativeInfinity 方法。

適用於

另請參閱