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

注意

IsNaN如果 Double 值為 PositiveInfinityNegativeInfinity ,則傳 false 回 。 若要測試這些值,請使用 IsInfinityIsPositiveInfinityIsNegativeInfinity 方法。

適用於

另請參閱