fixed size integer arithmetic

Richard B. Kreckel kreckel at
Mon Sep 3 21:50:16 CEST 2007

Evan Lavelle wrote:
> CLN might have been a useful starting point, but it doesn't appear to 
> have the bitwise operators, apart from << and >>, and >> seems to have a 
> restriction on N. There's also the issue of operations on elements of 
> different modular rings. There's nothing wrong, in principle, in adding 
> a 9-bit integer to a 191-bit integer, to get a 191-bit result (or 
> vice-versa), but CLN won't let you do this. It could be handled at a 
> higher level, but you'd then need an op to resize integers, which I 
> can't find.

Coercion of an element of one modular integer ring R1 into an element of 
a second modular integer ring R2 ("resizing") can be assembled using:
   cl_MI R1->canonhom (const cl_I& x)
   cl_I  R2->retract (const cl_MI& x)

Richard B. Kreckel

More information about the gmp-discuss mailing list