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 Huan, mark.dickinson, umedoblock, valhallasw, zach.ware
Date 2017-07-30.11:27:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1501414065.91.0.90985112241.issue24827@psf.upfronthosting.co.za>
In-reply-to
Content
Huan,

This isn't a bug: see the earlier comments from Zachary Ware on this issue for explanations. When you compute `rounded(1.45, 0.1)`, you convert the *float* 1.45 to a Decimal instance. Thanks to the What You See Is Not What You Get nature of binary floating point, the actual value stored for 1.45 is:

1.4499999999999999555910790149937383830547332763671875

Conversion from float to Decimal is exact, so the Decimal value you're working with is also a touch under 1.45:

>>> from decimal import Decimal
>>> Decimal(1.45)
Decimal('1.4499999999999999555910790149937383830547332763671875')

And so it correctly rounds down to `1.4`.
History
Date User Action Args
2017-07-30 11:27:45mark.dickinsonsetrecipients: + mark.dickinson, valhallasw, umedoblock, zach.ware, Huan
2017-07-30 11:27:45mark.dickinsonsetmessageid: <1501414065.91.0.90985112241.issue24827@psf.upfronthosting.co.za>
2017-07-30 11:27:45mark.dickinsonlinkissue24827 messages
2017-07-30 11:27:45mark.dickinsoncreate