Table of Contents

Method IsNaN

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

IsNaN(double)

Determines whether the specified double-precision floating-point value is NaN (Not a Number). This method uses bit-level inspection for performance-critical scenarios.

public static bool IsNaN(double value)

Parameters

value double

The value to evaluate.

Returns

bool

true if the value is NaN; otherwise, false.

Examples

IsNaNFast(double.NaN)              // returns true
IsNaNFast(0.0)                     // returns false
IsNaNFast(double.PositiveInfinity) // returns false
IsNaNFast(double.NegativeInfinity) // returns false
IsNaNFast(1.0 / 0.0)               // returns false (infinity)
IsNaNFast(0.0 / 0.0)               // returns true (NaN)

Remarks

IEEE 754: NaN values have all exponent bits set (0x7FF) and a non-zero mantissa. This avoids the overhead of IsNaN(double) and is suitable for tight loops.

IsNaN(float)

Determines whether the specified single-precision floating-point value is NaN (Not a Number). This method uses bit-level inspection.

public static bool IsNaN(float value)

Parameters

value float

The value to evaluate.

Returns

bool

true if the value is NaN; otherwise, false.

Examples

IsNaN(float.NaN);               // returns true
IsNaN(0f);                      // returns false
IsNaN(float.PositiveInfinity);  // returns false
IsNaN(float.NegativeInfinity);  // returns false
IsNaN(1f / 0f);                 // returns false (infinity)
IsNaN(0f / 0f);                 // returns true (NaN)