Integer arithmetic

Grant Edwards grante at visi.com
Wed Mar 26 22:48:38 EST 2003


In article <mailman.1048726543.12143.python-list at python.org>, James Gregory wrote:
> On Thu, 2003-03-27 at 00:37, Grant Edwards wrote:
>> In article <mailman.1048723363.12776.python-list at python.org>, James Gregory wrote:
>> 
>> >>> Am I so far off in thinking maybe this should be provided by
>> >>> the language?
>> >> 
>> >> IMHO, you are.  "integral types with N bits ignoring overflows"
>> > 
>> > So wait, all you want to do is algebra in the ring Z_{2^32}?
>> 
>> Don't know about him, but what I want to do is 2's compliment
>> add and subtract, bitwise and/or/not/xor and left/right shift
>> operations on 8, 16, and 32 bit values.  If that's "algebra in
>> the ring Z_{2^8|16|32}, then yes.
> 
> I was always better at number theory than coding theory. I think you
> want to work in {Z_2}^32 - If you really wanna do it then I still hold
> that just wrapping it all up into a class is the way to go.
[...]
> Grab a book on coding theory. Hamming is The Man IIRC.

IMO,it would be simpler to just write an extenstion in C and use C's
operators on 8, 16, and 32 bit integer data variables.

-- 
Grant Edwards                   grante             Yow!  Remember, in 2039,
                                  at               MOUSSE & PASTA will
                               visi.com            be available ONLY by
                                                   prescription!!




More information about the Python-list mailing list