[Tutor] Unexpected result from decimal
Jacob S.
keridee at jayco.net
Thu Jan 20 03:54:23 CET 2005
Hi all,
I'm having a problem that is ticking me off. (to put it lightly)
Why does decimal do this -- I thought that getcontext().prec was number of
decimal places?
>>> import decimal
>>> decimal.getcontext().prec = 2
>>> a = decimal.Decimal(2)
>>> b = decimal.Decimal(3)
>>> 100*a/b
Decimal("67")
>>> print 100*a/b
67
>>>
Why does it do this?
It's really, really, messing things up for me because results are not
interpreted in my programs correctly.
Jacob
More information about the Tutor
mailing list