ldexp()

All Math methods

ldexp() returns the mantissa and exponent of an input number.
ldexp(m,e) # output n 
n : is the output number
m : is the mantissa , a floating point number
e : is the exponent , an integer

Relation between output number with Mantissa ( m ) and exponent ( e )
n == m * 2**e
Example
import math
print(math.ldexp(2,3))  # 16.0 
With negative numbers
print(math.ldexp(-2,3)) # -16.0
print(math.ldexp(2,-3)) # 0.25
The second argument ( exponent ) has to be an integer, we can't use float.
print(math.ldexp(2.2,-3.3))
This will generate an TypeError

We can also use frexp() the inverse function of ldexp() to get Mantissa and exponent of n

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer