|
Boost : |
From: Gabriel Dos Reis (Gabriel.Dos-Reis_at_[hidden])
Date: 2001-05-22 03:16:20
John Max Skaller <skaller_at_[hidden]> writes:
| > However, intermediate results can overflow whereas
| > the exact final result could be represented in the given floating
| > point datatype as you acknowledge it here:
|
| Yes, except I refer to an _integer_ not floating
| representation.
Actually, I should have said "numerical datatype".
| > That is why a trait-based solution can give best of both worlds.
|
| I do not see how. My concern is that 'traits' are
| global, and that rounding, etc, must in general be managed
| locally. Perhaps I misunderstand what you mean by traits,
| but I'm thinking of a global 'rounding mode' flag,
| and that isn't something I like at all, because I don't
| think that, for example, the rounding mode is something
| that should be the same for all multiplications:
From the outset, my proposal is that the numerical datatypes will be
parameterised by a trait which does some very atomic operations
(pretty much like what std::char_trait<> does for std::basic_string<>).
And usual operations will be implemented in terms of that trait.
That means, there will be a separate trait-function for rouding, a
separate trait-function for adding or multiplying without rounding or
converting from one precision to another.
| 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.
-- Gaby
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk