[docs] [issue29710] Incorrect representation caveat on bitwise operation docs

Nick Coghlan report at bugs.python.org
Sun Jul 15 01:55:01 EDT 2018


Nick Coghlan <ncoghlan at gmail.com> added the comment:

The restriction of the footnote to ``x & y``, ``x | y``, and ``x ^ y`` was going to come from the fact that only those rows in the table will reference the new note. However, it likely makes sense to repeat the relevant expressions in the footnote as well, since that makes it clearer what ``x`` and ``y`` refer to in the second sentence.

Latest proposal:

=================
The results of ``x | y``,  ``x ^ y``, and ``x & y`` are calculated as though carried out in two's complement with an infinite number of sign bits. In practice, performing the calculation with at least one extra sign extension bit (a working bit-width of ``1 + max(x.bit_length(), y.bit_length()`` or more) is sufficient to get the expected result.
=================

----------

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


More information about the docs mailing list