a print bug?

Summercoolness at gmail.com Summercoolness at gmail.com
Wed Jul 26 09:36:57 EDT 2006


it seems that the behavior of "print" is that it will round off
properly for any floating point imperfection, such as shown in the
first two samples.  The third sample seems to be a bug?  It doesn't
know how to handle the floating imperfection in this case.

>>> 1.2345
1.2344999999999999

>>> print 1.2345
1.2345

>>> print "%10.3f" % 1.2345    # seems like a bug ----------------------------------
     1.234

>>> print "%10.3f" % 1.23450001
     1.235

>>> print "%10.3f" % 1.2344
     1.234

>>> print "%10.3f" % 1.2346
     1.235




More information about the Python-list mailing list