Boost logo

Boost :

From: Maarten Kronenburg (M.Kronenburg_at_[hidden])
Date: 2006-05-29 17:39:07

"Christoph Ludwig" <cludwig_at_[hidden]> wrote in message
> 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
> of reasoning:
> 1) There are applications where integers with negative values don't make
> sense.
> But that is merely a special case of variables with a restricted
> range. There are also bigint applications where a variable can only
> prime values or square free values or... Such restrictions are no less
> common than the case of non-negative integers, at least in my
> from computer algebra and cryptography.
> Therefore, as David Abrahms pointed out, there should rather be a
> solution for restricted types.
The unsigned_integer is actually a modular_integer with
any modulus, although when the modulus is zero,
it can be any non-negative integer.
But users can make other integer classes with other
This is why these member functions and operators
are virtual in the first place.

> 2) The native unsigned type is an integral type with mod 2^n semantics.
> there should also be a bigint type with mod 2^n semantics.
> Then why restrict yourself to the modulus 2^n? All arbitrary length
> packages I am familiar with also provide modular arithmetic for
> modulus N. (Even if you cannot exploit the factorization of the
> modular arithmetic is much more efficient than integer arithmetic
> 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
> arbitrary and gratuitous.

As mentioned above, the unsigned_integer is
actually a modular_integer with any modulus,
that can be set with the static function
So it is not restricted to modulus of form 2^n.
Users can also make a template with an
unsigned_integer data member, and provide
the modulus as a template non-type parameter.

> Christoph
> --
> FH Worms - University of Applied Sciences
> Fachbereich Informatik / Telekommunikation
> Erenburgerstr. 19, 67549 Worms, Germany
> _______________________________________________
> Unsubscribe & other changes:

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