If the second argument is 1 0 then the result is the same as the first argument.
Math power function java.
This function accepts two parameters and returns the value of first parameter raised to the second parameter.
If you want to return integer from power function you need to explicitly cast it to integer.
The math pow function returns the base to the exponent power that is base exponent the base and the exponent are in decimal numeral system.
The return type of pow method is double.
Special cases if the second argument is positive or negative zero then the result is 1 0.
In this quick article we have seen how to use the java s math pow method to calculate the power of any given base.
Because pow is a static method of math you always use it as math pow rather than as a method of a math object you created math has no constructor.
When you run above program you will get below output.
There are some special cases as listed below.
If the base is negative and the exponent is.
Power function in java is used to calculate a number raised to the power of some other number.
The java lang math pow is used to calculate a number raise to the power of some other number.
The java lang math pow is used to return the value of first argument raised to the power of the second argument.
Like always the full source code is available over on github.
The java lang math pow double a double b returns the value of the first argument raised to the power of the second argument.