Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. #
  4. # Copyright (c) 2010 Doug Hellmann. All rights reserved.
  5. #
  6. """From mantissa, exponent pair to floating point value.
  7. """
  8. #end_pymotw_header
  9.  
  10. import math
  11.  
  12. print '{:^7} {:^7} {:^7}'.format('m', 'e', 'x')
  13. print '{:-^7} {:-^7} {:-^7}'.format('', '', '')
  14.  
  15. for m, e in [ (0.8, -3),
  16. (0.5, 0),
  17. (0.5, 3),
  18. ]:
  19. x = math.ldexp(m, e)
  20. print '{:7.2f} {:7d} {:7.2f}'.format(m, e, x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement