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 amaury.forgeotdarc
Recipients amaury.forgeotdarc, shlomoa
Date 2007-12-07.10:13:47
SpamBayes Score 0.020389875
Marked as misclassified No
Message-id <1197022428.03.0.981209687631.issue1565@psf.upfronthosting.co.za>
In-reply-to
Content
Your function is not better:

>>> print my_round(s,2)
1.41
>>> my_round(s,2)
1.4099999999999999

print uses str(), and restricts itself to 12 significant digits.
the direct call uses repr(), and display the most precise number.

The problem is not in the computation, but is inherent to the 'float'
type which cannot represent 1.41 exactly. Please carefully read the faq
entry above.
History
Date User Action Args
2007-12-07 10:13:48amaury.forgeotdarcsetspambayes_score: 0.0203899 -> 0.020389875
recipients: + amaury.forgeotdarc, shlomoa
2007-12-07 10:13:48amaury.forgeotdarcsetspambayes_score: 0.0203899 -> 0.0203899
messageid: <1197022428.03.0.981209687631.issue1565@psf.upfronthosting.co.za>
2007-12-07 10:13:48amaury.forgeotdarclinkissue1565 messages
2007-12-07 10:13:47amaury.forgeotdarccreate