103
Java Math.sqrt() method
The java.lang.Math.sqrt() is used to return the square root of a number.
Syntax
Parameter
Return
- If the argument is positive double value, this method will return the square root of a given value.
- If the argument is NaN or less than zero, this method will return NaN.
- If the argument is positive infinity, this method will return positive Infinity.
- If the argument is positive or negative Zero, this method will return the result as Zero with same sign.
Example 1
Output:
9.0
Example 2
Output:
NaN
Example 3
Output:
NaN
Example 4
Output:
Infinity
Example 5
Output:
0.0
Next TopicJava Math