Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-05-22 21:55:05

Gabriel Dos Reis wrote:

> | I don't see that the rounding mode is a property of the data,
> | it is property of each individual operation.
> No. Rounding is the act of taking an exact result and producing an
> approximation within the range of numerical datatype; that is a
> function defined on a superset of the actual datatype, with values in
> the set of values of the datatype. It is independent of individual
> operations.

        I don't think this works. Just consider

        decimal<n> * decimal<m>

There is no 'universal' way to round the results. The scale
of the result depends on the arguments AND the operation.
What you seem to be suggesting is a pair of maps:

        LIFT: decimal<n> -> exact decimal
        ROUND: exact decimal -> decimal<n>

But actually, there is a family of maps:

        ROUND<n>: exact decimal -> decimal<n>

and the choice of which ROUND map to use
_depends on the operation_ being performed.
It will differ for addition and multiplication.

The model fails completely for division,
since the remainder will always be zero (or close to it).

Perhaps you can be more precise?

John (Max) Skaller, mailto:skaller_at_[hidden]
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper
download Interscript

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