Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2002-10-19 14:31:41

----- Original Message -----
From: "Joel de Guzman" <djowel_at_[hidden]>

> > I don't have a good answer here.
> > Most computers (that I've played with over the years) gave the answer
> > modulo (max value + 1) and a flag (or trap) commonly called overflow.
> > Most HLLs just give answer modulo (max value +1) and no way to even
> > overflow.
> > IMO, you're breaking new ground here (unfortunately)
> 1. AFAIK, what you are saying is implementation defined
> 2. There's a reason why modulo is not an option (sloooow, if I'm not
> 3. Boost PP *IS* breaking new ground
> Again 2c worth.

No. 1 speaks for itself. No. 2 would be easy for addition and hard for
multiplication. For an idea of the kind of speeds we're talking about here,
substraction and addition with saturation take a constant 0.06 seconds on
Comeau C++ on my laptop. Multiplication takes slightly longer than that.
Division and modulus I have yet to optimize thoroughly yet, so I can't say
exactly. However, it will depend a great deal on the operands. (BTW, I'm
come to the conclusion that division is evil because you have to make
guesses an than correct them if the are off.) Addition, substraction, and
multiplication are all non-recursive. They have a macro depth of
approximately 8, so they work fine on everything. Division and modulus *is*
recursive, and therefore the macro of depth of the calculation is much
higher. Altogether, except for *extremely* simple cases, high-precision
arithmetic will be much faster than the currently library arithmetic.

Paul Mensonides

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