From: Helmut Zeisel (helmut.zeisel_at_[hidden])
Date: 2001-06-20 23:39:39


20 Jun 2001 David B. Held wrote:
> >Is there any interest in an unlimited integer class?
> >
> >I wrote an unlimited integer class
> >using the classical O(n**2) algorithms
> >for multiplication and division,
> >so it works reasonable fast up to some 100 decimal digits.
>
> I wonder if it would be even more generally useful if it were
> generalized to a fixed-point representation? Just an idea.

IMHO an unlimited integer class might be
a good starting point for several generalizations,
such as the already existing boost::rational
or some fixed-point or high precision floating point classes.
I am not sure, however, whether they should be directly implemented
in the integer class or whether an independent adapter
(such as boost::rational) could do the same job.

> Did you implement it in a binary representation or something
> like BCD?
>

The radix (and its type) is a template parameter,
so the radix can portably be everything from 2 to 65536
(and perhaps 2**32 on a 64 bit machine).
The boolean operators &,|, and ^, however,
work only corresponding to our conventional logic
when the radix is a power of 2 ;-)

Using char digits with radix 10, you can have a kind of BCD.
You have, however, only one decimal digit per byte,
not two digit as in real BCD.

Helmut Zeisel