new bitwise module [was Re: Discussion: new operators ...]

Andrew Kuchling akuchlin at mems-exchange.org
Wed Aug 2 17:37:46 EDT 2000


"Rainer Deyke" <root at rainerdeyke.com> writes:
> All bitwise operators except ~ (which could be redefined as ~a = a ^
> 0xffffffff, with strange but predictable results for a > 0xffffffff) still
> make sense for long integers.  

Why couldn't ~ just assume twos-complement and have ~a = -(a+1)?  (Or
whatever the expression for twos-complement bitwise negation works out
to; I never remember if it's +1 or -1.) 

>>> ~12345678901234567890L
-12345678901234567891L

--amk



More information about the Python-list mailing list