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

ParameterRequiredDescription
xYesA numeric value.
iYesAn 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)
Run Code Copy

Output

ldexp(x, i) : 44.0

Summary

In this Python Math tutorial, we learned the syntax of, and examples for math.ldexp() function.

Related Tutorials

Code copied to clipboard successfully 👍