bitwise not - not what I expected

Elaine Jackson elainejackson7355 at home.com
Sun Aug 17 09:05:13 EDT 2003


"Tim Peters" <tim.one at comcast.net> wrote in message
news:mailman.1061098645.13097.python-list at python.org...

<snip>
| To understand your example above, note that
| binary 10010 actually has an unbounded number of 0 bits "to the left":
|
|     ...00000010010 = 13
|
| The bitwise inversion of that therefore has an unbounded number of 1 bits
| "to the left":
|
|     ...11111101101 = -19

** What you're saying, the way I read it, is that 5+S=(-19), where S is the
(divergent) sum of all the powers 2^k of 2 with k>=5. I'm still at sea, in other
words.

<snip>
| Python can't *guess* how many bits you want to keep.

**  But it could if someone had told it that the leftmost nonzero digit is the
place to start. I just assumed somebody had told it that.

<snip>
| Python represents negative integers in unbounded 2's-complement form

** Now we're getting someplace. That was the missing piece in my puzzle.

Thanks for the help.

Peace,
EJ






More information about the Python-list mailing list