- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Double.IsNaN() Method in C#
The Double.IsNaN() method in C# is used to return a value that indicates whether the specified value is not a number (NaN).
Syntax
The syntax is as follows −
public static bool IsNaN (double val);
Above, val is the double-precision floating-point number.
Example
Let us now see an example −
using System; public class Demo { public static void Main(){ double d = 1.0/0.0; Console.WriteLine("Double Value = "+d); Console.WriteLine("HashCode of Double Value = "+d.GetHashCode()); TypeCode type = d.GetTypeCode(); Console.WriteLine("TypeCode of Double Value = "+type); Console.WriteLine("Positive Infinity? = "+Double.IsInfinity(d)); Console.WriteLine("Check whether the specified value is NaN? = "+Double.IsNaN(d)); } }
Output
This will produce the following output −
Double Value = ∞ HashCode of Double Value = 2146435072 TypeCode of Double Value = Double Positive Infinity? = True Check whether the specified value is NaN? = False
Example
Let us now see another example −
using System; public class Demo { public static void Main(){ double d = 0.0/0; Console.WriteLine("Double Value = "+d); Console.WriteLine("HashCode of Double Value = "+d.GetHashCode()); TypeCode type = d.GetTypeCode(); Console.WriteLine("TypeCode of Double Value = "+type); Console.WriteLine("Positive Infinity? = "+Double.IsInfinity(d)); Console.WriteLine("Check whether the specified value is NaN? = "+Double.IsNaN(d)); } }
Output
This will produce the following output −
Double Value = NaN HashCode of Double Value = -524288 TypeCode of Double Value = Double Positive Infinity? = False Check whether the specified value is NaN? = True
Advertisements