Trusted answers to developer questions

Fouzia Bashir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The ** math.ldexp() method** is used to compute the expression

`x * (2**i)`

.** ldexp()** is the inverse function of

`frexp()`

.The

takes one argument and returns`frexp()`

method`mantissa`

m and exponent e as a tuple`(m,e)`

.

```
math.ldexp(x, i)
```

`ldexp`

takes two signed numbers as parameters:

`x`

*(float value)*: the first argument is basically mantissa`m`

.`i`

*(integer value)*: the second argument is basically exponent`e`

.

To understand this concept, learn about the

`frexp()`

method first.

This method calculates and returns the value of this expression: `x * (2**i)`

.

In the code snippet below, we pass two arguments to the `math.ldexp()`

method, which returns the result of `x * (2**i)`

on different argument values.

# Load maths module import math x=2 i=4 # demo examples print(math.ldexp(x, i)) print(math.ldexp(8, 4)) print(math.ldexp(12, -3)) print(math.ldexp(-7, 2))

RELATED TAGS

python

communitycreator

CONTRIBUTOR

Fouzia Bashir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Related Courses