This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients
Date 2007-08-21.01:02:43
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
This isn't really a bug---it's just one of those unavoidable things that happens when you're representing decimals using binary floating point:  take a look at section 4.3 of the General Python FAQ:

http://www.python.org/doc/faq/general/

If anything *is* wrong here it's actually the round() result, not the string formatting: 74.425 isn't exactly representable as a binary floating-point number, so Python (like most other languages) approximates it by the closest number that *is* exactly representable, which is (on my machine and probably yours too):

74.4249999999999971578290569595992565155029296875

Since this is less than 74.425, the round function would, in an ideal world, round this down to 74.42 instead of up to 74.43.  In the absence of an ideal world, making this sort of thing happen reliably and portably is hard, and I'd guess that round() is unlikely to change.

Have you looked at the decimal module in the standard library?  It sounds as though you might find it useful.



History
Date User Action Args
2007-08-23 14:59:22adminlinkissue1778207 messages
2007-08-23 14:59:22admincreate