StrictMath pow() Method in Java
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.
Syntax:
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.
Examples :
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:
Program 1:
// Java praogram to illustrate the // java.lang.StrictMath.pow() import java.lang.*; public class Geeks { public static void main(String[] args) { double num1 = 12, num2 = 6; // It returns num1 to the power num2 double pow_Value = StrictMath.pow(num1, num2); System.out.print(num1 + " to the power of " + num2 + " = "); System.out.println(pow_Value); double pow_Value1 = StrictMath.pow(num1, 0); double pow_Value2 = StrictMath.pow(num1, 0); System.out.println(num1+" raised to the"+ " power 0 = " + pow_Value1); System.out.println(num2+" raised to the"+ " power 0 = " + pow_Value2); } } |
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
Program 2:
// Java praogram to illustrate the // java.lang.StrictMath.pow() import java.lang.*; public class Geeks { public static void main(String[] args) { double num1 = 4.7, num2 = 2.5; // It returns num1 to the power num2 double pow_Value = StrictMath.pow(num1, num2); System.out.print(num1 + " to the power of " + num2 + " = "); System.out.println(pow_Value); } } |
4.7 to the power of 2.5 = 47.88997880559147
Recommended Posts:
- StrictMath tan() Method in Java
- StrictMath log() Method In Java
- StrictMath exp() Method in Java
- StrictMath sin() Method in Java
- StrictMath sinh() Method in Java
- StrictMath ulp() Method In Java with Examples
- StrictMath nextUp() Method in Java
- StrictMath signum() Method in Java
- StrictMath min() Method in Java with Examples
- StrictMath random() Method in Java
- StrictMath sqrt() Method in Java
- StrictMath getExponent() Method In Java
- StrictMath toDegrees() Method in Java
- StrictMath atan2() Method in Java
- StrictMath log10() 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 contribute@geeksforgeeks.org. 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.

