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 valhallasw
Recipients umedoblock, valhallasw, zach.ware
Date 2015-08-08.10:52:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439031149.55.0.270447565265.issue24827@psf.upfronthosting.co.za>
In-reply-to
Content
As Zachary explained, the behavior is correct. There are three issues in play here.

1) The rounding method. With the ROUND_HALF_EVEN rounding mode, .5 is rounded to the nearest *even* number, so 1.65 is rounded to 1.6, while 1.75 is rounded to 1.8.

2) Rounding of floats. Floats cannot represent every number, and numbers are therefore rounded.

 - round(2.675, 2) = round(2.6749999999999998, 2) and is thus rounded to 2.67
 - round(1.65, 1) = round(1.6499999999999999, 1) and is thus rounded to 1.6

3a) In Python 2, round returns a float, so Decimal(round(Decimal("1.65"))) = Decimal(1.6) =  Decimal('1.600000000000000088817841970012523233890533447265625') != Decimal('1.6')

3b) In Python 3, Decimal.__round__ is implemented, so round(D("1.65"), 1) == D("1.6") as expected.
History
Date User Action Args
2015-08-08 10:52:29valhallaswsetrecipients: + valhallasw, umedoblock, zach.ware
2015-08-08 10:52:29valhallaswsetmessageid: <1439031149.55.0.270447565265.issue24827@psf.upfronthosting.co.za>
2015-08-08 10:52:29valhallaswlinkissue24827 messages
2015-08-08 10:52:28valhallaswcreate