Double.IsNaN(Double) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳一個值,指示該指定值是否為數字(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
一個雙精度浮點數。
傳回
true若d評估為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若值false為 Double 或 PositiveInfinity,則返回NegativeInfinity。 要測試這些值,請使用 IsInfinity、 IsPositiveInfinity和 IsNegativeInfinity 方法。