StrictMath.sqrt() in Java

StrictMath.sqrt(): This method is available in java.lang.StrictMath class of Java.

Syntax:

double java.lang.StrictMath.sqrt(double a)

This method takes one argument of type double as its parameter. This method returns the correctly rounded positive square root of a double value.

Note:

1. If the argument is NaN or less than zero, then the resultis NaN.

2. If the argument is positive infinity, then the result is positiveinfinity.

3. If the argument is positive zero or negative zero, then the result is the same as the argument. Otherwise, the result is the double value closest tothe true mathematical square root of the argument value.

Parameters: One parameter is required for this method.

a: a value.

Returns: the positive square root of a.

Exceptions: NA

Approach

Java

public class StrictMathsqrt {
    public static void main(String[] args) {

        double a = 625;
        System.out.println(StrictMath.sqrt(a));
    }
}

Output:

25.0


No comments:

Post a Comment