Feb-14-2019, 06:24 PM
Hi everyone, I have a problem with precision in decimal, I want got 10 numbers after coma, but with context 10 I got 15, why? Thanks.
with localcontext() as ctx:
... ctx.prec = 10
... print(Decimal('1.0000000000') * Decimal('0.0000042372'))
...
0.000004237200000
>>> with localcontext() as ctx:
... ctx.prec = 5
... print(Decimal('1.0000000000') * Decimal('0.0000042372'))
with localcontext() as ctx:
... ctx.prec = 10
... print(Decimal('1.0000000000') * Decimal('0.0000042372'))
...
0.000004237200000
>>> with localcontext() as ctx:
... ctx.prec = 5
... print(Decimal('1.0000000000') * Decimal('0.0000042372'))