Single.IsNaN(Single) Método

Definição

Devolve 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.

Devoluções

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

Implementações

Exemplos

O seguinte exemplo de código 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(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

Observações

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

Note

IsNaNretorna false se um Single valor for ou PositiveInfinity .NegativeInfinity Para testar estes valores, utilize-se os IsInfinitymétodos , IsPositiveInfinity, e IsNegativeInfinity .

Aplica-se a

Ver também