Does Python need a '>>>' operator?

David Eppstein eppstein at ics.uci.edu
Tue Apr 16 02:36:19 EDT 2002


In article <m3ads4maa1.fsf at mira.informatik.hu-berlin.de>,
 martin at v.loewis.de (Martin v. Loewis) wrote:

> Unfortunately, you cannot represent such a number in hex, atleast not
> under any of the usual conventions: the convention is that you can
> strip infinitely many leading zeroes, but stripping off infinitely many
> leading ones is confusing.

I don't understand why not.

Exactly the same difficulty applies to decimal representations (you can 
strip off leading 0's but not leading 9's) but we have no trouble 
representing negative numbers in decimal: just write a minus sign 
followed by the decimal string for the absolute value of the number.

Similarly, the obvious and only way of representing a negative number in 
hex is to write a minus sign followed by the hex string for the absolute 
value of the number.

The "usual" way of representing 32-bit values in hex, ffff0123 etc, has 
nothing to do with negative numbers, it is a way of representing 
unsigned values.  Since Python doesn't have unsigned values, we 
shouldn't do things that way.

-- 
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/



More information about the Python-list mailing list