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 felix.engelmann
Recipients felix.engelmann
Date 2018-02-22.10:02:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519293751.66.0.467229070634.issue32908@psf.upfronthosting.co.za>
In-reply-to
Content
As described in https://www.python.org/dev/peps/pep-0327/#rounding-algorithms
round-half-up: If the discarded digits represent greater than or equal to half (0.5) then the result should be incremented by 1; otherwise the discarded digits are ignored.

Rounding 9.95 to 1 decimal with ROUND_HALD_UP results in 9.9 instead of 10.0:
 
Decimal(9.95).quantize(Decimal('1.1'),ROUND_HALF_UP)
Out[49]: Decimal('9.9')

It does not matter at wich position this rounding with influence on another digit happens:

Decimal(9.995).quantize(Decimal('1.11'),ROUND_HALF_UP)
Out[50]: Decimal('9.99')

It is a specific problem with the 5, because 9.96 works as expected

Decimal(9.96).quantize(Decimal('1.1'),ROUND_HALF_UP)
Out[40]: Decimal('10.0')

System:

Python 3.6.4

import decimal
decimal.__version__ : '1.70'
History
Date User Action Args
2018-02-22 10:02:31felix.engelmannsetrecipients: + felix.engelmann
2018-02-22 10:02:31felix.engelmannsetmessageid: <1519293751.66.0.467229070634.issue32908@psf.upfronthosting.co.za>
2018-02-22 10:02:31felix.engelmannlinkissue32908 messages
2018-02-22 10:02:31felix.engelmanncreate