Boost logo

Boost :

From: Gabriel Dos Reis (Gabriel.Dos-Reis_at_[hidden])
Date: 2001-05-21 18:24:59

John Max Skaller <skaller_at_[hidden]> writes:

| My 'gut feeling' on this is that the basic
| calculations don't involve rounding at all.
| They're exact.

They are exact only if there is no overflow using a grammar school
algorithm. However, intermediate results can overflow whereas
the exact final result could be represented in the given floating
point datatype as you acknowledge it here:

| ... One problem with this approach
| is that overflow on multiply occurs before rounding:
| if the rounding is 'built-in' to the multiply, it is possible
| to avoid overflow in some cases:
| decimal<n> mul<n>(decimal<n> a, decimal<n> b)
| is more general and could avoid overflows (by, for example,
| scaling the arguments first, before multiplying).

And that situation is not uncommon.

Yes. That is why a trait-based solution can give best of both worlds.

-- Gaby

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