Skip to content
class method

Math.ldexp

(::Math::double fraction, ::int exponent) -> ::Float
Math.ldexp(fraction, exponent) → float

Returns the value of fraction * 2**exponent.

  • Domain of fraction: [0.0, 1.0).

  • Domain of exponent: [0, 1024] (larger values are equivalent to 1024).

See IEEE 754 double-precision binary floating-point format: binary64.

Examples:

Example
ldexp(-INFINITY, -1) # => -Infinity
ldexp(-0.5, 2)       # => -2.0
ldexp(-0.5, 1)       # => -1.0
ldexp(0.0, 0)        # => 0.0
ldexp(-0.5, 1)       # => 1.0
ldexp(-0.5, 2)       # => 2.0
ldexp(INFINITY, -1)  # => Infinity

Related: Math.frexp (inverse of Math.ldexp).

See also .hypot .lgamma .gamma .log also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0