Freigeben über


Double.NaN-Feld

Stellt einen Wert dar, der keine Zahl ist (NaN). Dieses Feld ist konstant.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Const NaN As Double
'Usage
Dim value As Double

value = Double.NaN
public const double NaN
public:
literal double NaN
public static final double NaN
public const var NaN : double

Hinweise

Der Wert dieser Konstanten ist das Ergebnis einer Division von 0 (null) durch 0 (null).

Diese Konstante wird zurückgegeben, wenn das Ergebnis einer Operation undefiniert ist.

Verwenden Sie die IsNaN-Methode, um festzustellen, ob ein Wert keine Zahl ist. Durch einen Vergleich mit einem anderen NaN-Wert ist nicht feststellbar, ob ein Wert keine Zahl ist.

Beispiel

Das folgende Codebeispiel veranschaulicht die Verwendung von NaN:

Dim zero As Double = 0

' This condition will return false.
If (0 / zero) = Double.NaN Then
    Console.WriteLine("0 / 0 can be tested with Double.NaN.")
Else
    Console.WriteLine("0 / 0 cannot be tested with Double.NaN; use Double.IsNan() instead.")
End If
Double zero = 0;

// This condition will return false.
if ((0 / zero) == Double.NaN) 
{
    Console.WriteLine("0 / 0 can be tested with Double.NaN.");
} 
else 
{
    Console.WriteLine("0 / 0 cannot be tested with Double.NaN; use Double.IsNan() instead.");
}
Double zero = 0;

// This condition will return false.
if ( (0 / zero) == Double::NaN )
{
   Console::WriteLine( "0 / 0 can be tested with Double::NaN." );
}
else
{
   Console::WriteLine( "0 / 0 cannot be tested with Double::NaN; use Double::IsNan() instead." );
}
Double zero = new Double(0);

// This condition will return false.
if (0 / zero.doubleValue() == Double.NaN) {
    Console.WriteLine("0 / 0 can be tested with Double.NaN.");
}
else {
    Console.WriteLine(
        "0 / 0 cannot be tested with Double.NaN; " 
        + "use Double.IsNan() instead.");
}

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

Double-Struktur
Double-Member
System-Namespace
IsNaN