Single.IsNaN(Single) Método

Definição

Retorna um valor que indica se o valor especificado não é um 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

Um número de ponto flutuante de precisão simples.

Retornos

true se f não for avaliado como um número (NaN); caso contrário, false.

Implementações

Exemplos

O exemplo de código a seguir demonstra o 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

Comentários

As operações de ponto flutuante retornam NaN para sinalizar que o resultado da operação é indefinido. Por exemplo, dividir 0,0 por 0,0 resulta em NaN.

Observação

IsNaN retornará false se um Single valor for PositiveInfinity ou NegativeInfinity. Para testar esses valores, use os IsInfinitymétodos , IsPositiveInfinitye IsNegativeInfinity .

Aplica-se a

Confira também