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 zach.ware
Recipients umedoblock, zach.ware
Date 2015-08-08.03:13:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439003633.17.0.806991261669.issue24827@psf.upfronthosting.co.za>
In-reply-to
Content
The rounding mode of the default context is ROUND_HALF_EVEN[1]:

>>> import decimal
>>> decimal.getcontext()
Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999, capitals=1, clamp=0, flags=[], traps=[InvalidOperation, DivisionByZero, Overflow])

For your examples near the end, see [2]:

>>> round(2.675, 2)
2.67
>>> round(decimal.Decimal('2.675'), 2)
Decimal('2.68')
>>> decimal.Decimal(2.675)
Decimal('2.67499999999999982236431605997495353221893310546875')
>>> round(_, 2)
Decimal('2.67')

[1] https://docs.python.org/3/library/decimal.html#decimal.ROUND_HALF_EVEN
[2] https://docs.python.org/3/tutorial/floatingpoint.html
History
Date User Action Args
2015-08-08 03:13:53zach.waresetrecipients: + zach.ware, umedoblock
2015-08-08 03:13:53zach.waresetmessageid: <1439003633.17.0.806991261669.issue24827@psf.upfronthosting.co.za>
2015-08-08 03:13:53zach.warelinkissue24827 messages
2015-08-08 03:13:52zach.warecreate