How to get the mantissa and exponent of x, as pair (m, e), m is a float and e is an int in Python

1 Answer

0 votes
import math

print(math.frexp(20))
print(math.frexp(16.2))
print(math.frexp(-20))
print(math.frexp(-14.5))


'''
run:

(0.625, 5)
(0.50625, 5)
(-0.625, 5)
(-0.90625, 4)

'''

 



answered Oct 13, 2017 by avibootz
...