Single.IsNaN(Single) Método

Definición

Devuelve un valor que indica si el valor especificado no es un número (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

Parámetros

f
Single

Número de punto flotante de precisión sencilla.

Devoluciones

Boolean

Es true si f se evalúa como un valor no numérico (NaN); en caso contrario, es false.

Implementaciones

Ejemplos

En el ejemplo de código siguiente se muestra el IsNaN método .

// 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(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

Comentarios

Las operaciones de punto flotante devuelven NaN para indicar que el resultado de la operación no está definido. Por ejemplo, dividir 0,0 por 0,0 da como NaNresultado .

Nota

IsNaN devuelve false si un Single valor es PositiveInfinity o NegativeInfinity. Para probar estos valores, use los IsInfinitymétodos , IsPositiveInfinityy IsNegativeInfinity .

Se aplica a

Consulte también