Single.IsNaN(Single) Metodo

Definizione

Restituisce un valore che indica se il valore specificato non è un numero (NaN).

public:
 static bool IsNaN(float f);
public:
 static bool IsNaN(float f) = System::Numerics::INumberBase<float>::IsNaN;
public static bool IsNaN(float f);
static member IsNaN : single -> bool
Public Shared Function IsNaN (f As Single) As Boolean

Parametri

f
Single

Numero a virgola mobile e precisione singola.

Valori restituiti

true se f restituisce un numero (NaN); in caso contrario, false.

Implementazioni

Esempio

Nell'esempio di codice seguente viene illustrato il IsNaN metodo .

// This will return true.
if (Single.IsNaN(0 / zero))
{
    Console.WriteLine("Single.IsNan() can determine whether a value is not-a-number.");
}
// This will return true.
if Single.IsNaN(0f / zero) then
    printfn "Single.IsNan() can determine whether a value is not-a-number."
' This will return true.
If Single.IsNaN(0 / zero) Then
    Console.WriteLine("Single.IsNan() can determine whether a value is not-a-number.")
End If

Commenti

Le operazioni a virgola mobile restituiscono NaN un segnale che il risultato dell'operazione non è definito. Ad esempio, dividendo 0,0 per 0,0 restituisce NaN.

Note

IsNaN restituisce false se un Single valore è PositiveInfinity o NegativeInfinity. Per testare questi valori, usare i IsInfinitymetodi , IsPositiveInfinitye IsNegativeInfinity .

Si applica a

Vedi anche