[New-bugs-announce] [issue39301] Specification of bitshift on integers should clearly state floor division used
report at bugs.python.org
Sat Jan 11 01:59:44 EST 2020
New submission from Nick Coghlan <ncoghlan at gmail.com>:
While reviewing ISO-IECJTC1-SC22-WG23's latest draft of their Python security annex, I noticed that https://docs.python.org/3.7/library/stdtypes.html#bitwise-operations-on-integer-types doesn't explicitly state that *floor* division is used for right shift operations, so right-shifting a negative number by more bits than it contains gives -1 rather than 0.
This is consistent with the way the language spec defines both binary right-shifts (as division by "pow(2, n)" and floor division (as rounding towards negative infinity), so this is just a documentation issue to note that we should make it clearer that this behaviour is intentional.
assignee: docs at python
nosy: docs at python, ncoghlan
stage: needs patch
title: Specification of bitshift on integers should clearly state floor division used
versions: Python 3.7, Python 3.8, Python 3.9
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce