Boost logo

Boost :

From: Helmut Zeisel (helmut.zeisel_at_[hidden])
Date: 2001-07-04 23:52:33


John Max Skaller wrote:
> Helmut Zeisel wrote:
>

>
> The basic interface is trivially obvious.
> You need the basic operations:
>
> add, subtract, multiply, quotient_and_remainder
> comparisons
>
> and probably some mutators.

ACK.

> The hard part is what _other_
> operations to provide. In particular, conversions to
> and from WHICH other types?

Did you already have a look at my interface?
Thanks to operator.hpp most of this is already present.

In particular, we have conversion from and mixed arithmetic
with every built-in integral type.

There is conversion from/to every built-in floating point type,
but no mixed arithmetics with floating point.
(What type should the result be?)

> What about a specialised
> multiply and divide by 10? What about n_digits?
> Log2?

Yes, this should be discussed.

>
> for example, you really MUST have n_digits, so you can
> estimate how big a char array to allocate to fit
> the string representation of the number in.

We are speaking C++, not C.

>
> My point is that it isn't possible to discover what you
> really need in an interface with an implementation that
> isn't trying to provide the fastest possible way to calculate.
>

OTOH, the interface must not restric the possible implementation too much.
Maybe a adifferent implentation can add some (optional) optimizations.
 
> Here's the big int interface from the Ocaml big_int module,
> note that at the time this was written, Ocaml only had one
> size of integer (int).
>
> type big_int
> ...

Did you have a look at my interface?
Most of this is already present (again thanks to operator.hpp)
I will check in detail, however.

>
> and here's the one for unsigned numbers:
>
> type nat
>

This is a good point.
I only have signed integers.
Do we really need unsigned unlimited integers?
What should be static_cast<nat>(-1)?

Helmut


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk