|
Boost : |
From: Bill Seymour (bill-at-the-office_at_[hidden])
Date: 2002-03-12 14:59:36
Vadim wrote:
>
> Ideally, fixed-point arithmetic shoud yield a kind of
> floating-point result, preserving as much precision as
> possible/makes sence. Rounding should not occur until
> assignment at which point it determined by the target
> type's rounding policy.
>
But that would require some kind of infinite-precision type.
I wouldn't want to wait for that.
I had a little time on my hands yesterday and today;
so I rewrote the decimal class both with a second
template argument for a rounding policy, and with
a data member that keeps the rounding mode on a
per-instance basis and allows changing the mode
at run time (it's just an ordinary pointer to function,
so it's not a heavyweight solution). I think that
both are cleaner than my original design; so unless
anybody else cares a great deal, I'll go with Jeff's
basic idea.
That still leaves the question of whether the rounding
mode should be a compile-time thing or a run-time
thing. I'm leaning toward the latter...it's simple
to implement; and it gives the user more options.
--Bill Seymour
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk