On Wed, 22 Feb 2012 21:39:20 +0000, Tom Anderson

<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who

said :

>These numbers will mostly not be more than a bilion, and will probably

>never be more than a hundred billion. Some of them, i will need to

>represent to eight decimal places
So long max 9,223,372,036,854,775,807 would be sufficient, except for

intermediate results? I had a similar problem back in 1985

implementing a 32-bit forth on a 16-bit 8086 architecture.

If your results are still 64 bits, just collecting the low order bits

will work.

If you need 128 bits, you could do it like this for unsigned multiply.

split your two numbers into two 32 bit quantities

a = bc

d = ef

a * d = c*f + (b*f + c*e) >> 32 + (b*e) >> 64

In assembler this is easier since you get the high bits too as a

matter of course from a multiply.

If you don't need much, rolling your own based on the way you did it

in grade 4 (considering your numbers as base 2^32 numbers rather than

base 10). might be much easier than introducing a full library.

In the process I bested Knuth and came up with a more efficient

multiprecision division algorithm.

--

Roedy Green Canadian Mind Products

http://mindprod.com
One of the most useful comments you can put in a program is

"If you change this, remember to change ?XXX? too".