> then I saw that Python has the same problems as well with Decimal …
What makes you believe that?
>>> from decimal import Decimal as d, ROUND_HALF_UP >>> (d('0.565') * 100).quantize(d(1), ROUND_HALF_UP) / 100 Decimal('0.57') >>> (d('0.575') * 100).quantize(d(1), ROUND_HALF_UP) / 100 Decimal('0.58')
Decimal also supports rounding directly, instead of doing arbitrary computations:
>>> d('0.565').quantize(d('0.01'), ROUND_HALF_UP) Decimal('0.57') >>> d('0.575').quantize(d('0.01'), ROUND_HALF_UP) Decimal('0.58')
> then I saw that Python has the same problems as well with Decimal …
What makes you believe that?
>>> from decimal import Decimal as d, ROUND_HALF_UP
>>> (d('0.565') * 100).quantize(d(1), ROUND_HALF_UP) / 100
Decimal('0.57')
>>> (d('0.575') * 100).quantize(d(1), ROUND_HALF_UP) / 100
Decimal('0.58')
Decimal also supports rounding directly, instead of doing arbitrary computations:
>>> d('0.565' ).quantize( d('0.01' ), ROUND_HALF_UP) ).quantize( d('0.01' ), ROUND_HALF_UP)
Decimal('0.57')
>>> d('0.575'
Decimal('0.58')