Does Python need a '>>>' operator?
Martin v. Loewis
martin at v.loewis.de
Tue Apr 16 02:36:54 EDT 2002
"Ken Peek" <Ken.Peek at SpiritSongDesigns.comNOSPAM> writes:
> | That is only meaningful for positive numbers - it just doesn't work
> | for twos complement.
[...]
> Ahhhh!!! Got'cha!!!!
>
> Python DOESN'T HAVE UNSIGNED NUMBERS!!!
Why are you shouting at me? I didn't say "unsigned numbers", I said
"positive numbers". Python has infinitely many of those - assuming you
have enough memory to represent them :-)
> Since there is no way to know this happened to or object, we either
> have to make an overly complex "Rube Goldberg" type exploration, if
> we want to be able to do a logical right shift of an int-long
> object.
Just restrict yourself to positive numbers, and the logical shift is
the same as the arithmetic shift.
> THAT is the reason for the '>>>' operator-- the designers of Java
> got rid of unsigned integers, because many programming mistakes
> happened in 'C' with them in existence-- this (in turn) necessitated
> the creation of a different operator for 'arithmetic right shift',
> and 'logical right shift'.
The other reason, of course, is that they still wanted to represent 32
logical bits in a single int value. In Python, you can represent
arbitrary many bits in a positive number, and the right-shift will be
"logical".
> Quite frankly, I don't give a damn HOW the long (or int) is represented
> internally to the machine
Good, neither do I. I wonder why you bring up internal representation
then all the time.
> Is what I want so EVIL that Python can't do things that way?
No, it is impossible to do what you want - you have not presented a
single consistent specification, yet, which is also implementable.
Regards,
Martin
More information about the Python-list
mailing list