[issue39301] Specification of bitshift on integers should clearly state floor division used

Mark Dickinson report at bugs.python.org
Sun May 24 06:17:45 EDT 2020


Mark Dickinson <dickinsm at gmail.com> added the comment:

> I confess that I've no idea what the "without overflow check" bit means

After some digging, it is indeed to do with the int/long unification:

- In Python 2.1, arithmetic operations on ints would raise OverflowError on overflow.
- Except that left shift did not raise: shifted out bits were simply lost.  This is described in PEP 237.

In Python 2.2, arithmetic operations (including left shift) were changed to produce a long instead of overflowing.

The "without overflow check" part of the doc almost certainly refers to the Python 2.1 behaviour (at least for left shift; I'm guessing that for right shift, where overflow isn't possible, this was just a redundant copy-paste), and was never updated. It should be removed for both left shift and right shift.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39301>
_______________________________________


More information about the Python-bugs-list mailing list