Description
The pow
function calculates the value of the base base
raised to the exponent exponent
and returns the result.
Syntax
pow(base, exponent)
Arguments
Argument | Description |
---|---|
base |
The base of the exponentiation. |
exponent |
The exponent to which the base is raised. |
Return Value
The function returns the result of the calculation base
exponent
as a number.
Examples
Description | Example |
---|---|
Square of a number |
pow(3, 2)Result: 9 |
Cube of a number |
pow(2, 3)Result: 8 |
Negative exponents |
pow(2, -2)Result: 0.25 |
Exponent equal to zero |
pow(5, 0)Result: 1 |
Notes
- If the exponent
0
is provided, the function always returns1
regardless of the base (except when the base is0
, which leads to an error). - Negative exponents calculate the reciprocal of the power. For example,
pow(2, -2)
equals1 / (22)
.
Comments
0 comments
Please sign in to leave a comment.