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.
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 dout special cases:
- The function returns NaN if the argument is NaN or less than zero
- The function returns positive infinity when the argument is positive infinite.
- The function returns zero with the same sign as the argument if the argument is zero
- The result is the double value nearest to the mathematical square root of the argument value.
Input: num = 25 Output: 5.0 Input: -729 Output: NaN
Below programs illustrate the use of java.lang.StrictMath.sqrt() method:
square root = 17.0 square root = NaN square root = 0.0 square root = 23.406622994357814
square root = 34.058772731852805 square root = NaN square root = -0.0 square root = 12.0 square root = NaN
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Java sqrt() method with Examples
- BigInteger sqrt() Method in Java
- StrictMath log() Method In Java
- StrictMath sin() Method in Java
- StrictMath exp() Method in Java
- StrictMath tan() Method in Java
- StrictMath pow() Method in Java
- BigDecimal sqrt() Method in Java with Examples
- StrictMath hypot() Method in Java
- StrictMath fma() method in Java with Examples
- StrictMath multiplyExact() Method in Java
- StrictMath sinh() Method in Java
- StrictMath IEEEremainder() Method in Java
- StrictMath tanh() Method in Java
- StrictMath scalb() Method in Java
- StrictMath nextUp() Method in Java
- StrictMath atan2() Method in Java
- StrictMath ulp() Method In Java with Examples
- StrictMath signum() Method in Java
- StrictMath atan() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.