65
Java Double isNaN() Method
The isNaN() method of Java Double class returns true:
- If the value of this Object is Not-a-Number (NaN).
- If the argument passed is Not-a-Number (NaN).
- 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
Output:
Infinity-false 0.0-false NaN-true
Example 2
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
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