math.pow
Defined in module
"math"from "math" import powReturns x raised to the power y
Parameters
x | number | the base |
y | number | the exponent |
Return value
x raised to the power y, as a float.
Notes
The result is always a float, even when both x and y are integers: type(pow(2, 3)) is "float".
Out-of-domain input does not throw. A negative x with a fractional y gives NaN; x equal to 0 with a negative y gives infinity. Both print differently between compilers and platforms, so do not print them from portable code.
Example
from "math" import pow
println("pow(2, 10) =", pow(2, 10))
println("pow(2.0, 0.5) =", pow(2.0, 0.5))
// integer arguments still give a float result
println("type(pow(2, 3)) =", type(pow(2, 3)))Output:
pow(2, 10) = 1024
pow(2.0, 0.5) = 1.41421
type(pow(2, 3)) = floatSee also
sqrt | Returns the square root of x |
exp | Returns e raised to the power of x |
log | Returns the natural logarithm of x |
| math | module index |