[issue42936] Decimal module performs wrong floor division with negative numbers
Mark Dickinson
report at bugs.python.org
Fri Jan 15 10:38:05 EST 2021
Mark Dickinson <dickinsm at gmail.com> added the comment:
The behaviour is deliberate, if unfortunate: it's covered in the documentation here: https://docs.python.org/3/library/decimal.html#decimal-objects - see the paragraph starting
> There are some small differences between arithmetic on Decimal objects
> and arithmetic on integers and floats. When the remainder operator % is
> applied to Decimal objects
The issue is that the decimal spec specifies "divide-integer" and "remainder" operations. We've chosen to map those operations to "%" and "//" for convenience, even though there's a difference between float and Decimal here.
----------
nosy: +mark.dickinson
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42936>
_______________________________________
More information about the Python-bugs-list
mailing list