Comment 1 for bug 1372624

Revision history for this message
Gediminas Paulauskas (menesis) wrote :

The problem is default decimal rounding setting of ROUND_HALF_EVEN (on 5 round to closest even number).

>>> print '{:.2}'.format(decimal.Decimal('6.75'))
6.8

>>> average = decimal.Decimal('6.85')

>>> print '{:.1f}'.format(average)
6.8

>>> ctx = decimal.Context(rounding=decimal.ROUND_HALF_UP)

>>> with decimal.localcontext(ctx):
    print '{:.1f}'.format(average)
...
6.9

Read https://docs.python.org/2/library/decimal.html