C# Double IsNaN

Description

Double IsNaN returns a value that indicates whether the specified value is not a number (NaN).

Syntax

Double.IsNaN has the following syntax.


public static bool IsNaN(
  double d
)

Parameters

Double.IsNaN has the following parameters.

  • d - A double-precision floating-point number.

Returns

Double.IsNaN method returns true if d evaluates to NaN; otherwise, false.

Example

The following code example illustrates the use of IsNaN: Double.IsNan() can determine whether a value is not-a-number.


using System;//w w  w. j a v a 2  s .com

public class MainClass{
  public static void Main(String[] argv){  
    // This will return true. 
    int zero = 0;
    if (Double.IsNaN(0 / zero)) 
       Console.WriteLine("true");

  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version