Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.ldexp() Method

Python math.ldexp() Method

Python math Module Python math Module

Python math.ldexp(x, i) The method returns x * (2**i),math.frexp() the inverse function of.

Python version: 2.6

Syntax

The syntax of the math.ldexp() method is as follows:

math.ldexp(x, i)

Parameter Description:

Return Value

A floating-point value returning x * (2**i)

Example

The following example computes x * (2**i):

Example

Import the math package

import

math

Return x * (2**i)

print

(

math

.

ldexp

(

9

,

3

)

)

print

(

math

.

ldexp

(

5

,

2

)

)

print

(

math

.

ldexp

(

15

,

2

)

)

Output result:


72.0
-20.0
60.0

Python math Module Python math Module