Python math.ldexp() - x * 2^i
Python math.ldexp()
math.ldexp(x, i) function returns the result of x * (2^i).
Syntax
The syntax to call ldexp() function is
math.ldexp(x, i)
where
Parameter | Required | Description |
---|---|---|
x | Yes | A numeric value. |
i | Yes | An integer value. |
Example
In the following program, we find the result of ldexp(x, i) for x=5.5 and i = 3.
Python Program
import math
x = 5.5
i = 3
result = math.ldexp(x, i)
print('ldexp(x, i) :', result)
Output
ldexp(x, i) : 44.0
Summary
In this Python Math tutorial, we learned the syntax of, and examples for math.ldexp() function.