[New-bugs-announce] [issue11131] decimal.py: plus/minus with ROUND_FLOOR
Stefan Krah
report at bugs.python.org
Sat Feb 5 19:04:49 CET 2011
New submission from Stefan Krah <stefan-usenet at bytereef.org>:
Another exciting corner case in plus/minus:
"The operations are evaluated using the same rules as add and subtract;
the operations plus(a) and minus(a) (where a and b refer to any numbers)
are calculated as the operations add(’0’, a) and subtract(’0’, b)
respectively, where the ’0’ has the same exponent as the operand."
But add and subtract have a special rule for the sign with ROUND_FLOOR:
"Otherwise, the sign of a zero result is 0 unless either both operands
were negative or the signs of the operands were different and the
rounding is round-floor."
So, +Decimal("-0") and -Decimal("0") should be a negative zero. I checked
this against decNumber. Currently:
>>> c = getcontext()
>>> c.rounding = ROUND_FLOOR
>>> +Decimal("-0")
Decimal('0')
>>> -Decimal("0")
Decimal('0')
----------
components: Library (Lib)
messages: 128007
nosy: mark.dickinson, skrah
priority: normal
severity: normal
status: open
title: decimal.py: plus/minus with ROUND_FLOOR
type: behavior
versions: Python 3.2, Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11131>
_______________________________________
More information about the New-bugs-announce
mailing list