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

Rainer Deyke root at rainerdeyke.com
Wed Aug 2 18:30:09 EDT 2000


"Andrew Kuchling" <akuchlin at mems-exchange.org> wrote in message
news:3dittjgx91.fsf at kronos.cnri.reston.va.us...
> "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

Because that leaves ~0 inconsistent with existing code.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware action/role-playing games      -      http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list