Message248247
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 |
|
Date |
User |
Action |
Args |
2015-08-08 03:13:53 | zach.ware | set | recipients:
+ zach.ware, umedoblock |
2015-08-08 03:13:53 | zach.ware | set | messageid: <1439003633.17.0.806991261669.issue24827@psf.upfronthosting.co.za> |
2015-08-08 03:13:53 | zach.ware | link | issue24827 messages |
2015-08-08 03:13:52 | zach.ware | create | |
|