[issue42936] Decimal module performs wrong floor division with negative numbers

2021-01-15 Thread Mark Dickinson


Mark Dickinson  added the comment:

Thanks for the report. I'm going to close here, since this isn't a bug.

If you want to advocate for a behaviour change, by all means go ahead, but be 
aware that it would likely be a hard sell. The main challenge would be finding 
a way to change the behaviour that doesn't abruptly break existing code that 
depends on the current semantics.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue42936] Decimal module performs wrong floor division with negative numbers

2021-01-15 Thread Mark Dickinson


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

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



[issue42936] Decimal module performs wrong floor division with negative numbers

2021-01-15 Thread Jens


New submission from Jens :

from decimal import Decimal

print(-0.9//0.123)
# prints -8.0
print(Decimal('-0.9')//Decimal('0.123'))
# prints -7
print(-10//4.2)
# prints -3.0
print(Decimal('-10')//Decimal('4.2'))
# prints -2

--
messages: 385113
nosy: multiks2200
priority: normal
severity: normal
status: open
title: Decimal module performs wrong floor division with negative numbers
versions: Python 3.8

___
Python tracker 

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