Does Python need a '>>>' operator?
Ken Peek
Ken.Peek at SpiritSongDesigns.comNOSPAM
Sat Apr 13 19:14:21 EDT 2002
"Martin v. Loewis" <martin at v.loewis.de> wrote in message
news:m3sn5z1axf.fsf at mira.informatik.hu-berlin.de...
| "Ken Peek" <Ken.Peek at SpiritSongDesigns.comNOSPAM> writes:
|
| > Since Python does not have unsigned numbers, I think
Python should
| > have a (Java-like) '>>>' operator. The '>>>' means
| > 'logical-shift-right', where a zero is copied into the
high bit.
|
| Since the Python int and long int types are going to be
merged, I
| doubt that this will be added to the language.
The merging of the 'long int' and the 'int' type is
precisely WHY there _should_ be a '>>>' operator. Did you
read ALL of my post?
| One might question whether the bitwise operators should
have been
| there in the first place - functions can do the same
things just as
| well.
You _ARE_ joking about this, aren't you?
Let's say I want to work with a 64-bit number:
>>> a = 0x8000000000000000
>>> print hex(a >> 1)
0x4000000000000000L
# (I expected the above)...
>>> b = -a
>>> print hex(b >> 1)
-0x4000000000000000L
# !!! SURPRISE !!!
# (I expected -0xC000000000000000L !!!)
I think this should work the same way an 'int' does-- but I
don't know how to do that without breaking older code...
Very_bit_diddle'ly yours,
--Ken Peek
More information about the Python-list
mailing list