Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-05-15 13:17:48


Daniel Frey wrote:

>In finance there is another, sometimes important way of rounding: On a
>tie, round so that the last digit is even. To illustrate that:

Gabriel Dos Reis wrote:

> I think the ability of choosing rounding mode should not be
> overlooked. It is an essential part of LIA-1 and later standards.

I'm convinced.

So a question is do you support that by having a whole bunch of different
functions, or by the class template taking some kind of a parameter
(perhaps a traits or policy class) performing the rounding desired?

If different rounding rules are never mixed for a given fixed-point object,
it might be a lot cleaner to have one template parameter (which could
default to a useful rule) that having a huge number of very ugly, basically
duplicate, functions:

> mul_with_truncate(a,b)
> mul_with_rhlsd_up(a,b)
> mul_with_rhlsd_ran(a,b)
> mul_with_noround(a,b)

and then it later turning out that there was yet another rounding rule
needed.

--Beman


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