Math module

pow

procedure · 2 overloadsSource

x raised to y, for float and float64 (the float form computes in float64 and rounds). Whole exponents below 2^31 use repeated multiplication, so pow(x, 2) is exactly x * x. Edge cases: y == 0 or x == 1 gives 1 even for NaN; any other NaN gives NaN; a negative x with a non-whole y gives NaN; a zero x with negative y gives infinity.

ExampleOpen in playground ↗
assert(pow(cast(float64) 2, 10) == 1024);
assert(pow(cast(float64) 2, -2) == 0.25);
assert(pow(cast(float64) -2, 3) == -8);
assert(isnan(pow(cast(float64) -8, 0.5)));
assert(pow(FLOAT64_NAN, 0) == 1);
pow :: (x: float64, y: float64) -> float64

x raised to the power y.

Parameters

x: float64
the base.
y: float64
the exponent.

Returns

float64
pow :: (x: float, power: float) -> float

x raised to power.

Parameters

x: float
the base.
power: float
the exponent.

Returns

float

See also