ldexp function

double ldexp(
  1. num x,
  2. int exp
)

Computes the result of multiplying the floating-point number x by 2 raised to the power exp. result = x * 2^exp.

Example:

print(ldexp(0.5, 3)); // 4.0

Implementation

double ldexp(num x, int exp) {
  // Simple implementation using pow, optimization possible with bit ops
  return (pow(2, exp) * x).toDouble();
}