[issue29710] Incorrect representation caveat on bitwise operation docs
Martin Panter
report at bugs.python.org
Sun Nov 5 21:58:35 EST 2017
Martin Panter <vadmium+py at gmail.com> added the comment:
I find the model in terms of “bit_length” hard to understand. You have to understand what bit_length returns, and why you added 1. Bit_length is awkward for negative numbers. It only uses the absolute value, which would give off-by-one problems with negative values, so I guess you added 1 to compensate.
I understand the bitwise operations as using two’s complement extended to an unlimited width, so that negative values have a series of ones for the most-significant bits. I presume this is what your “2-adic representation” is. Having this spelled out may have helped when I was learning Python.
----------
nosy: +martin.panter
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue29710>
_______________________________________
More information about the Python-bugs-list
mailing list