programming-examples/python/Math/Print the floating point from mantissa, exponent pair.py
2019-11-15 12:59:38 +01:00

11 lines
352 B
Python

import math
print('{:^7} {:^8} {:^17}'.format('Mantissa', 'Exponent', 'Floating point value'))
print('{:-^8} {:-^8} {:-^20}'.format('', '', ''))
for m, e in [ (0.7, -3),
(0.3, 0),
(0.5, 3),
]:
x = math.ldexp(m, e)
print('{:7.2f} {:7d} {:7.2f}'.format(m, e, x))