C# Single IsNaN

Description

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

Syntax

Single.IsNaN has the following syntax.


public static bool IsNaN(
  float f
)

Parameters

Single.IsNaN has the following parameters.

  • f - A single-precision floating-point number.

Returns

Single.IsNaN method returns true if f evaluates to not a number (NaN); otherwise, false.

Example

The following code example demonstrates the IsNaN method.


/*from w w  w. j  a  v a  2 s . c  o  m*/
using System;
public class MainClass
{
    public static void Main(String[] argv)
    {
        float zero = 0.0F;
        // This will return true. 
        if (Single.IsNaN(0 / zero))
        {
            Console.WriteLine("Single.IsNan() can determine whether a value is not-a-number.");
        }

    }
}
    

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