[New-bugs-announce] [issue39301] Specification of bitshift on integers should clearly state floor division used

Nick Coghlan 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
components: Documentation
messages: 359786
nosy: docs at python, ncoghlan
priority: normal
severity: normal
stage: needs patch
status: open
title: Specification of bitshift on integers should clearly state floor division used
type: enhancement
versions: Python 3.7, Python 3.8, Python 3.9

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


More information about the New-bugs-announce mailing list