Easy Tutorial
❮ Python Func Number Modf Python Func Number Abs ❯

Python math.ldexp() Method

Python math Module

The math.ldexp(x, i) method in Python returns x * (2**i), which is the inverse of math.frexp().

Python Version: 2.6

Syntax

The syntax for the math.ldexp() method is as follows:

math.ldexp(x, i)

Parameter Descriptions:

Return Value

A floating-point value, returning x * (2**i).

Example

The following example calculates x * (2**i):

Example

# Import math package
import math

# Return x * (2**i)
print(math.ldexp(9, 3))
print(math.ldexp(-5, 2))
print(math.ldexp(15, 2))

Output results:

72.0
-20.0
60.0

Python math Module

❮ Python Func Number Modf Python Func Number Abs ❯