The java.lang.StrictMath.pow() is an inbuilt method of StrictMath class used to find the power value i.e., the value of one argument raised to the power of another argument. Mathematically it refers to . It gives rise to three special results:
- The method returns NaN when one argument is NaN and the other is a nonzero argument or NaN.
- The method returns the same as the first argument when the second argument is 1.0.
- The method returns 1.0 when the second argument is positive or negative zero.
public static double pow(double num1, double num2)
Parameters: The method accepts two parameter:
- num1: This is of double type and refers to the base.
- num2: This is of double type and refers to the exponent.
Return Value: The method returns the value of operation num1^num2.
Input: num1 = 6 num2 = 4 Output: 1296.0 Input: num1 = 5 num2 = 2 Output: 25.0
Below programs illustrate the java.lang.StrictMath.pow() method:
12.0 to the power of 6.0 = 2985984.0 12.0 raised to the power 0 = 1.0 6.0 raised to the power 0 = 1.0
4.7 to the power of 2.5 = 47.88997880559147
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.