Java Double isNaN() MethodThe isNaN() method of Java Double class returns true:
SyntaxParameters1.NA 2.' v ' is the double value to be tested. Return valueThe isNaN() method returns true if the argument specified is Not-a-Number(NaN), else returns false. Example 1Test it NowOutput: Infinity-false 0.0-false NaN-true Example 2Test it NowOutput: 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 3Test it NowOutput: 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
|