Boost logo

Boost :

From: Christoph Ludwig (cludwig_at_[hidden])
Date: 2006-05-29 12:39:02

On Mon, May 29, 2006 at 03:55:01PM +0200, Maarten Kronenburg wrote:
> In my opinion the unsigned integer with a modulus
> is required, which is generalizing the base type
> unsigned int (which is modular) to any modulus.

I don't understand your motivation for such a type. IIUC there are two lines
of reasoning:

1) There are applications where integers with negative values don't make any

   But that is merely a special case of variables with a restricted
   range. There are also bigint applications where a variable can only take
   prime values or square free values or... Such restrictions are no less
   common than the case of non-negative integers, at least in my experience
   from computer algebra and cryptography.

   Therefore, as David Abrahms pointed out, there should rather be a generic
   solution for restricted types.

2) The native unsigned type is an integral type with mod 2^n semantics. Thus,
   there should also be a bigint type with mod 2^n semantics.

   Then why restrict yourself to the modulus 2^n? All arbitrary length integer
   packages I am familiar with also provide modular arithmetic for arbitrary
   modulus N. (Even if you cannot exploit the factorization of the modulus,
   modular arithmetic is much more efficient than integer arithmetic followed
   by a modulus operation. In fact, I would have no use for a bigint
   implementation without efficient modular arithmetic.) Most important is
   certainly the case that N is prime, but composed moduli are also often
   needed. The special case N = 2^n may perhaphs be the easiest one to
   implement, but from a potential user's point of view such a choice seems
   arbitrary and gratuitous.


FH Worms - University of Applied Sciences
Fachbereich Informatik / Telekommunikation
Erenburgerstr. 19, 67549 Worms, Germany

Boost list run by bdawes at, gregod at, cpdaniel at, john at