[issue7630] Strange behaviour of decimal.Decimal

2010-01-04 Thread Mark Dickinson

Mark Dickinson  added the comment:

It might also help to note that, with decimal, what you see (from repr() of a 
Decimal instance) is *exactly* what you get.  So when you see

>>> dec
Decimal('1.797693134862315907729305191E+308')

that number really is exactly what's stored in dec:  there are no 'hidden'  
digits waiting to appear.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7630] Strange behaviour of decimal.Decimal

2010-01-04 Thread Mark Dickinson

Mark Dickinson  added the comment:

You don't say what behaviour you were expecting!   :)

By design, almost all Decimal operations (but not creation of a Decimal from an 
integer or string) round to the precision given by the current context.  By 
default that precision is 28 significant digits.  See the documentation, 
particularly the quick-start tutorial,

http://docs.python.org/library/decimal.html#quick-start-tutorial

for more information, including how to change the default precision.

--
nosy: +mark.dickinson
resolution:  -> invalid
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7630] Strange behaviour of decimal.Decimal

2010-01-03 Thread parmax

New submission from parmax :

>>> 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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com