![]() |
VOOZH | about |
The java.lang.StrictMath.sqrt() is an inbuilt method of StrictMath class in Java which is used to obtain the exact rounded positive square root of a specified double value. Syntax:
public static double sqrt(double num)
Parameters: The function accepts a single parameter num of double type, whose square root is to be returned by the function. Return Values: This method returns the positive square root of num. it also gives rise to doubt special cases:
Examples:
Input: num = 25 Output: 5.0 Input: -729 Output: NaN
Below programs illustrate the use of java.lang.StrictMath.sqrt() method: Program 1:
square root = 17.0 square root = NaN square root = 0.0 square root = 23.406622994357814
Program 2:
square root = 34.058772731852805 square root = NaN square root = -0.0 square root = 12.0 square root = NaN