Home >>Python math Module >Python math.ldexp() Method

Python math.ldexp() Method

Python math.ldexp() Method

Python math.ldexp() method is used to return x * (2**i) value of the given input number. It is also called as the inverse of the Python math.frexp() function.

Syntax:
math.ldexp(x, i)

Parameter Values

Parameter Description
x This is a required parameter. It defines any valid +ve or -ve number.
i This is a required parameter. It defines any valid +ve or -ve number.
Here is an example of Python math.idexp() method:

import math  
print(math.ldexp(9, 3)) 
print(math.ldexp(-5, 2))

Output:
72.0
-20.0
Example 2:

import math  
print(math.ldexp(3.5, 2)) 
print('%.2f' %math.ldexp(-6.8, 3))

Output:
14.0
-54.40