[code.view]

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

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Floating point modulo
     """
     #end_pymotw_header
     
     import math
     
     print '{:^4}  {:^4}  {:^5}  {:^5}'.format('x', 'y', '%', 'fmod')
     print '----  ----  -----  -----'
     
     for x, y in [ (5, 2),
                   (5, -2),
                   (-5, 2),
                   ]:
         print '{:4.1f}  {:4.1f}  {:5.2f}  {:5.2f}'.format(x, y, x % y, math.fmod(x, y))
     

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

contact | logmethods.com