This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients CuriousLearner, docs@python, mark.dickinson, martin.panter, ncoghlan, tim.peters, wolma
Date 2017-12-03.03:43:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
To answer the old accusation ;-), no, this isn't my wording.  I _always_ explain that Python's integer bit operations act as if the integers were stored in 2's-complement representation but with an infinite number of sign bits.  That's all.  That provides insight.

For example, then it's dead obvious that `-1 == ~0` (both an infinite solid string of 1 bits); that for any integer `i`, `-1 ^ i == ~i" (both flip each bit in `i`); and that for any positive integers `i` and `j` it's necessarily the case that `-i ^ -j` is positive (because the infinite strings of sign bits cancel out).

The reference manual is under no obligation to explain how to _implement_ this illusion, and I don't think it's helpful to try.  People here are struggling to explain how to pick a number of bits "big enough" to make it all work out on a case by case basis, but the single answer "infinity" is big enough to apply in all cases ;-)
Date User Action Args
2017-12-03 03:43:41tim.peterssetrecipients: + tim.peters, mark.dickinson, ncoghlan, docs@python, martin.panter, wolma, CuriousLearner
2017-12-03 03:43:41tim.peterssetmessageid: <>
2017-12-03 03:43:41tim.peterslinkissue29710 messages
2017-12-03 03:43:40tim.peterscreate