StrictMath.pow() in Java

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

Syntax:

double java.lang.StrictMath.pow(double a, double b)

This method takes two arguments of type double as its parameter. This method returns the value of the first argument raised to the power of the second argument.

Note:

1. If the second argument is positive or negative zero, then the result is 1.0.

2. If the second argument is 1.0, then the result is the same as the first argument.

3. If the second argument is NaN, then the result is NaN.

4. If the first argument is NaN and the second argument is nonzero, then the result is NaN.

Parameters: Two parameters are required for this method.

a: base.

b: the exponent.

Returns: the value a^b.

Exceptions: NA

Approach

Java

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

        double a = 191.56, b = 14;
        System.out.println(StrictMath.pow(a, b));
    }
}

Output:

8.959166282472238E31


No comments:

Post a Comment