YouTip LogoYouTip

Ref Math Ldexp

# Python math.ldexp() Method | # (#) * (javascript:void(0);) * (javascript:void(0);) * (javascript:void(0);) * (javascript:void(0)) Python 3 Tutorial (#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)")(#)(#)(#)(#)(#)(#)(#)(#)(#)[Python3 Namespace/Scope](#)(#)(#)(#)(#)(#) ## Advanced Python3 Tutorials (#)(#)[Python3 MySQL (mysql-connector)](#)[Python3 MySQL (PyMySQL)](#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#) x = 1.5 i = 3 result = math.ldexp(x, i) print(result) # Output: 12.0 The `math.ldexp()` function computes $ x times 2^i $ where `x` is a floating-point number and `i` is an integer. ### Syntax ```python math.ldexp(x, i) ### Parameters * `x`: A floating-point number. * `i`: An integer. ### Return Value Returns the value of $ x times 2^i $. ### Example ```python import math print(math.ldexp(1.5, 3)) # Output: 12.0 print(math.ldexp(2.0, 4)) # Output: 32.0 print(math.ldexp(-1.0, 2)) # Output: -4.0 In the above examples: * `math.ldexp(1.5, 3)` returns $ 1.5 times 2^3 = 1.5 times 8 = 12.0 $ * `math.ldexp(2.0, 4)` returns $ 2.0 times 2^4 = 2.0 times 16 = 32.0 $ * `math.ldexp(-1.0, 2)` returns $ -1.0 times 2^2 = -1.0 times 4 = -4.0 $ This function is useful for performing fast multiplication or division by powers of two in floating-point arithmetic. It's often used in numerical computations and signal processing applications. ### Related Topics ### See Also --- [![](#)](#) Β©2024 ALL RIGHTS RESERVED. (#) | (#) | (#) | (#)
← Ref Math ProdRef Math Lgamma β†’