fixed size integer arithmetic

Hans Aberg haberg at math.su.se
Wed Aug 29 19:17:40 CEST 2007


On 29 Aug 2007, at 12:23, Paul Leyland wrote:

>> I think the original spec. was unambiguous on this point.   As I read
>> it, he's asking for arithmetic in Z/Z_N where N is a fixed power  
>> of two.
>
> It should, of course, be "arithmetic in Z_N".  I don't know why a
> spurious "Z/" crept in.  I do know that I need to improve my proof
> reading.

The modern construction is Z_n := Z/nZ, the ring of integers Z  
divided out with the ideal nZ = (n) = {kn| k in Z}. One can also  
construct Z_n as Z divided out with the equivalence relation mod n.

As for the original question, n = 2^k, where k is the number of bits.  
If one uses 2s complement representation for signed integral types,  
the only difference between signed and unsigned integral types is the  
lifting of the coset representatives of Z_n into Z. So they can be  
replaced by a single type with different (signed/unsigned) printing  
functions.

   Hans Aberg




More information about the gmp-discuss mailing list