[code.view]

[top] / python / PyMOTW / math / math_frexp.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Separate mantissa from exponent.
     """
     #end_pymotw_header
     
     import math
     
     print '{:^7}  {:^7}  {:^7}'.format('x', 'm', 'e')
     print '{:-^7}  {:-^7}  {:-^7}'.format('', '', '')
     
     for x in [ 0.1, 0.5, 4.0 ]:
         m, e = math.frexp(x)
         print '{:7.2f}  {:7.2f}  {:7d}'.format(x, m, e)
     

[top] / python / PyMOTW / math / math_frexp.py

contact | logmethods.com