Double.IsNaN(Double) Metoda

Definicja

Zwraca wartość wskazującą, czy określona wartość nie jest liczbą (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

Parametry

d
Double

Liczba zmiennoprzecinkowa podwójnej precyzji.

Zwraca

true if d evaluates to NaN; w przeciwnym razie false.

Implementuje

Przykłady

Poniższy przykład kodu ilustruje użycie elementu 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

Uwagi

Operacje zmiennoprzecinkowe powrócą NaN do sygnału, że wynik operacji jest niezdefiniowany. Na przykład dzielenie wartości 0.0 przez 0,0 powoduje zwrócenie wartości NaN.

Uwaga

IsNaN Zwraca false wartość , jeśli Double wartość to PositiveInfinity lub NegativeInfinity. Aby przetestować te wartości, użyj IsInfinitymetod , IsPositiveInfinityi IsNegativeInfinity .

Dotyczy

Zobacz też