[issue7630] Strange behaviour of decimal.Decimal

parmax report at bugs.python.org
Mon Jan 4 06:41:58 CET 2010


New submission from parmax <md5xxx1 at gmail.com>:

>>> from decimal import Decimal
>>> dec = Decimal(2 ** 1024)
>>> dec
Decimal('179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216')
>>> dec += Decimal('0.1')
>>> dec
Decimal('1.797693134862315907729305191E+308')
>>> dec == Decimal(2 ** 1024) + Decimal('0.1')
True
>>> dec -= Decimal(2 ** 1024)
>>> dec
Decimal('2.109752663820230210576934273E+280')
>>> dec == Decimal('0.1')
False
>>>

----------
components: Library (Lib)
messages: 97192
nosy: parmax
severity: normal
status: open
title: Strange behaviour of decimal.Decimal
type: behavior
versions: Python 2.6

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


More information about the Python-bugs-list mailing list