bitwise not - not what I expected

Carl Banks imbosol at aerojockey.com
Sun Aug 17 18:08:15 EDT 2003


Elaine Jackson wrote:
> <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.


And if someone had done that, it would violate the invariant:

~(~x) == x

In fact, by repeatedly applying ~ you'd eventually zero all the bits.



-- 
CARL BANKS                   http://www.aerojockey.com/software
"You don't run Microsoft Windows.  Microsoft Windows runs you."




More information about the Python-list mailing list