To test if a float-point value is a NaN(Not a Number), use the method from float or double.
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine(double.IsNaN(0.0 / 0.0)); // True
}
}
The output:
True
We can also use the object.Equals to compare two NaN values.
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine(object.Equals(0.0 / 0.0, double.NaN)); // True
}
}
The output:
True
| w___w__w___._j_ava__2___s._c_om_ | Contact Us |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |