Math module

ldexp

procedure · 1 overloadSource

x * 2^pw2, computed exactly by exponent arithmetic (the inverse of frexp). An exponent beyond the range gives infinity or zero (with the sign of x), and the final underflow rounds once. Zero, infinities and NaN are returned unchanged. Only float64.

ExampleOpen in playground ↗
assert(ldexp(cast(float64) 0.5, 4) == 8);
assert(ldexp(cast(float64) 3, -1) == 1.5);
assert(isinf(ldexp(cast(float64) 1, 2000)));
ldexp :: (x: float64, pw2: s32) -> float64

x * 2^pw2.

Parameters

x: float64
the value to scale.
pw2: s32
the power of two to scale by.

Returns

float64

See also