System.Single.NaN Field

Represents not a number (NaN). This field is constant.

Value: NaN

Syntax

public const float NaN

Remarks

A method or operator returns float.NaN when the result of an operation is undefined. For example, the result of dividing zero by zero is float.NaN, as the following example shows. (But note that dividing a non-zero number by zero returns either float.PositiveInfinity or float.NegativeInfinity, depending on the sign of the divisor.)

code reference: System.Single.NaN#1

In addition, a method call with a float.NaN value or an operation on a float.NaN value returns float.NaN, as the following example shows.

code reference: System.Single.NaN#2

Use the float.IsNaN(float) method to determine whether a value is not a number. Two float.NaN values are considered unequal to one another. Therefore, it is not possible to determine whether a value is not a number by using the equality operator to compare it to another value that is equal to NaN. The comparison returns false, as the following example shows.

code reference: System.Single.NaN#3

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0