Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-05-09 14:48:04


At 02:45 PM 5/9/2001, John Max Skaller wrote:

>> - All operations are exact if there is no overflow and if no
>> rounding is required. Overflow is undefined behavior.
>> Rounding is done the way accountants do it: round to nearest
>> with 1/2-LSB always rounded "up." (I think "up" means "away
>> from zero." I've asked an accountant friend via e-mail but
>> haven't yet gotten an answer.)
>
> This is problematic. For some operations, it is
>wrong to always round 1/2 LSD up: when doing statistical
>operations, rounding up or down at random is correct.
>Sometimes, truncation is correct (rather than rounding).
>
> This suggests that you pick one mode (as you have)
>for the operator?? forms, but supply the other operations
>as named functions, for example
>
> mul_with_truncate(a,b)
> mul_with_rhlsd_up(a,b)
> mul_with_rhlsd_ran(a,b)
> mul_with_noround(a,b)

Maybe. But maybe just stick with one form of rounding, unless there really
is some overwhelming need for additional forms.

> ...
>
> It is also OK to leave this stuff out: a basic
>library is better than none, and much better than
>getting it completely wrong :-)

I second John's comment:-)

--Beman


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