Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-03-26 15:41:46


Jonathan Turkanis wrote:
> Peter, could you elaborate on why rounding is the only legitimate
> behaviour when using rational with a limited precision type?

Nice phrasing ;-) but I'll try.

Since rounding is a subset of unspecified, it can only be worse if it
carries an unacceptable overhead when overflow does not occur. I don't think
that this is the case here.

Asserting on overflow is misguided, because asserts should be used to catch
logic errors, and rationals rarely participate in program logic; the source
of the computation usually comes from user input.

Exception on overflow is only better than rounding if no result is better
than an approximate result, that is, when the answer has to be correct no
matter what. This requirement is better served by rational<unlimited> which
does deliver a correct answer. I don't see how
rational<limited>+exception-on-overflow is better.


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