[issue24827] round(1.65, 1) return 1.6 with decima modulel

umedoblock report at bugs.python.org
Sat Aug 8 07:38:41 CEST 2015


umedoblock added the comment:

I don't agree with "not a bug".

>>> s1, v1, ndigits1 = "1.65", 1.65, 1
>>> s2, v2, ndigits2 = "2.675", 2.675, 2

>>> decimal.Decimal(v1)
Decimal('1.649999999999999911182158029987476766109466552734375')
>>> round(v1, ndigits1)
1.6
>>> round(decimal.Decimal(s1), ndigits1)
Decimal('1.6') # EQUAL expression round(v1, ndigits1)

>>> decimal.Decimal(v2)
Decimal('2.67499999999999982236431605997495353221893310546875')
>>> round(v2, ndigits2)
2.67
>>> round(decimal.Decimal(s2), ndigits2)
Decimal('2.68') # DIFFERENT expression round(v2, ndigits2)

decimal module should give me different expression about below.
round(decimal.Decimal(s1), ndigits1) and round(v1, ndigits1).

BECAUSE

round(decimal.Decimal(s2), ndigits2) and round(v2, ndigits2)
give me DIFFERENT expression.

----------
title: round(1.65, 1) return 1.6 with decimal -> round(1.65, 1) return 1.6 with decima modulel

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24827>
_______________________________________


More information about the Python-bugs-list mailing list