Integer arithmetic

Grant Edwards grante at visi.com
Wed Mar 26 19:37:36 EST 2003


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.

> Assuming this is right, why not just make a RingElement class
> that has all the operators overloaded to perform the
> appropriate operation and then perform the appropriate modulus.
> With appropriate optimizations if needs be.

-- 
Grant Edwards                   grante             Yow!  I think I am an
                                  at               overnight sensation right
                               visi.com            now!!




More information about the Python-list mailing list