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

Tim Peters report at bugs.python.org
Sun Jul 15 01:05:50 EDT 2018


Tim Peters <tim at python.org> added the comment:

Nick, that seems a decent compromise.  "Infinite string of sign bits" is how Guido & I both thought of it when the semantics of longs were first defined, and others in this report apparently find it natural enough too.  It also applies to all 6 operations in the table as-is.

It appears that

    a bit-width of ``1 + max(x.bit_length(), y.bit_length()``
    
only applies as-is to 3 (~ has only one operand, while the bit length of the RHS doesn't matter for << and >>).  Provided that's clarified, I'd only suggest inserting "at least" before "one extra sign extension bit" and after "a bit-width of".  That's a bridge between the "infinite" and "fixed-albeit-variable-width" views:  "plus 1" is the smallest approximation to infinity that works, but anything at least that large works too.

----------

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


More information about the docs mailing list