Single.IsNaN(Single) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳一個值,指示該指定值是否為數字(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
參數
- f
- Single
一個單精度浮點數。
傳回
true 若 f 評估 非 數 (NaN;否則, false。
實作
範例
以下程式碼範例示範了此 IsNaN 方法。
// 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
備註
浮點運算回傳 NaN 為該運算結果未定義的信號。 例如,將 0.0 除以 0.0 得到 NaN。
Note
IsNaN若值false為 Single 或 PositiveInfinity,則返回NegativeInfinity。 要測試這些值,請使用 IsInfinity、 IsPositiveInfinity和 IsNegativeInfinity 方法。