Single.IsNaN(Single) Single.IsNaN(Single) Single.IsNaN(Single) Single.IsNaN(Single) Method

定义

返回一个值,该值指示指定的值是否不为数字 (NaN)。Returns a value that indicates whether the specified value is not a number (NaN).

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

参数

f
Single Single Single Single

单精度浮点数。A single-precision floating-point number.

返回

如果 f 计算为非数字 (NaN),则为 true;否则为 falsetrue if f evaluates to not a number (NaN); otherwise, false.

示例

下面的代码示例演示IsNaN方法。The following code example demonstrates the IsNaN method.

// 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(0 / zero) Then
    Console.WriteLine("Single.IsNan() can determine whether a value is not-a-number.")
End If

注解

浮点运算返回NaN到表示操作结果未定义的信号。Floating-point operations return NaN to signal that result of the operation is undefined. 例如,将0.0 除以0.0 会导致NaNFor example, dividing 0.0 by 0.0 results in NaN.

备注

IsNaN如果值为PositiveInfinityfalse ,则返回。Single NegativeInfinityIsNaN returns false if a Single value is either PositiveInfinity or NegativeInfinity. 若要测试这些值,请使用IsInfinityIsPositiveInfinityIsNegativeInfinity方法。To test for these values, use the IsInfinity, IsPositiveInfinity, and IsNegativeInfinity methods.

适用于

另请参阅