[New-bugs-announce] [issue12005] modulo result of Decimal differs from float/int

Daniel Albeseder report at bugs.python.org
Thu May 5 10:35:19 CEST 2011

New submission from Daniel Albeseder <kotan at gmx.at>:

I know that the modulo operation for negative values is not well defined, but I would at least expect that the result is the same no matter if you use ints, floats or decimals. However Decimal seem to behave else than the builtin types.

Python 3.1.2 (release31-maint, Sep 17 2010, 20:27:33) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from decimal import Decimal
>>> -3 % 5
>>> -3. % 5.
>>> Decimal(-3) % Decimal (5)

I could reproduce the same for python 2.6.6.

components: Library (Lib)
messages: 135176
nosy: Kotan
priority: normal
severity: normal
status: open
title: modulo result of Decimal differs from float/int
type: behavior
versions: Python 2.6, Python 3.1

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list