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

Mark Dickinson report at bugs.python.org
Sat Jan 11 14:10:47 EST 2020


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

Is the fix as simple as adding the word "floor" before "division" in the "equivalent to division by [...]" phrase?

> A right shift by n bits is equivalent to floor division by pow(2, n) without overflow check. 

This text was probably written before // was introduced; maybe we can rewrite in terms of //? "x >> n" should be identical to "x // pow(2, n)" for any nonnegative "n".

I confess that I've no idea what the "without overflow check" bit means, but I suspect it's no longer relevant post int/long-unification.

----------

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


More information about the Python-bugs-list mailing list