Tim Peters wrote:
> [Raymond Hettinger]

>>>>>from decimal import getcontext, Decimal as D
>>>>>getcontext().prec = 3
>>>>>D('3.104') + D('2.104')
>>
>>Decimal("5.21")
>>
>>>>>D('3.104') + D('0.000') + D('2.104')
>>
>>Decimal("5.20")
> 
> the results differ here because D(whatever)
> ignores context settings; having a common operation ignore context is
> ugly and error-prone).

I don't see it's because of that. Even if D(whatever)
didn't ignore the context settings, you'd get the same
oddity if the numbers came from somewhere else with a
different precision.

I'm very uncomfortable about the whole idea of a
context-dependent precision. It just seems to be
asking for trouble.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,          | A citizen of NewZealandCorp, a       |
Christchurch, New Zealand          | wholly-owned subsidiary of USA Inc.  |
[EMAIL PROTECTED]          +--------------------------------------+
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to