[OT] Number theory [Was: A use for integer quotients]

David Eppstein eppstein at ics.uci.edu
Mon Jul 30 07:13:18 CEST 2001

In article <3b645f76.747435355 at wa.news.verio.net>,
 bokr at accessone.com (Bengt Richter) wrote:

> ISTM that thinking of bit twiddling as operating on integers
> is not clean conceptually. I.e., I think there is an implicit
> coercion to a set type for the twiddle operation and then implicitly
> back to integer again when supposedly twiddling two integers
> with a binary twiddling operation (same for unary, of course).

Bit-twiddling operations like bitwise xor are generally not nice continuous 
operations on (binary representations of) real numbers, e.g. because 
0.11111... and 1.00000... are the same as real numbers but very different 
as bitstrings.

However, I think bit twiddling is nice and continuous if instead you use 
2-adic numbers (overcondensed tutorial: 2-adic integers are binary numbers 
where the bit sequence goes to infinity to the left instead of to the 
right, e.g. 3 1/4 = .....000011.01 -- just apply usual 2's complement 
arithmetic to these sequences and everything works).

Of course, this doesn't do much for your attempt to make this thread 
relevant to Python again...
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