Javatpoint Logo
Javatpoint Logo

Java Double isNaN() Method

The isNaN() method of Java Double class returns true:

  1. If the value of this Object is Not-a-Number (NaN).
  2. If the argument passed is Not-a-Number (NaN).
  3. Otherwise, the method returns false.

Syntax

Parameters

1.NA

2.' v ' is the double value to be tested.

Return value

The isNaN() method returns true if the argument specified is Not-a-Number(NaN), else returns false.

Example 1

Test it Now

Output:

Infinity-false
0.0-false
NaN-true

Example 2

Test it Now

Output:

Enter Positive double number = 
323
1. 323.0/0.0 - 323.0/0.0 = NaN value is true
2. 323.0/0.0 * 0.0 = NaN value is true
3. 323.0*0.0 / 0.0 = NaN value is true
4. NaN - 768943453 = NaN value is true
BUILD SUCCESSFUL (total time: 8 seconds)

Example 3

Test it Now

Output:

Enter two double no.
1. Enter Positive double number = 
94
Ans. Square root of 94.0 value = 9.69536018371582
2. Enter Negative double number =
-556
Ans. Square root of -556.0 value = NaN
BUILD SUCCESSFUL (total time: 16 seconds)

Next TopicJava Double





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA