|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-12-08 16:55:37
Guillaume Melquiond <guillaume.melquiond_at_[hidden]> writes:
>> > I agree the documentation should be clearer. As long as the variable of
>> > type I::traits_type::rounding is alive, then we are in a scope that is
>> > protected.
>>
>> Now you're changing terms again. I thought it was "unprotected!"
>
> The interval types are unprotected. So they have to be used in a scope
> that is protected.
I now understand what you mean, but find the terminology quite
confusable. The docs need a better explanation.
> Otherwise computations with them would lead to wrong results.
>
> Default interval types are protected against an unadapted environment:
> some code modifies the environment and restores it later on, so that the
> library computes a correct result. But this protection is costly
> performance-wise. So you unprotect these types to speed up the
> computations that involves them. But as a consequence, you can safely do
> these computations only in a manually protected block.
>
>> > In such a scope, floating-point computations will have strange
>> > behaviors, but computations involving unprotected intervals (they
>> > run a lot faster than computations involving correct intervals) are
>> > able to give correct results.
>>
>> Because rounding for ordinary numbers is supposed to be
>> "round-to-nearest" rather than "round up" or "round down" (at least
>> one of which is needed for interval arithmetic)?
>
> Right. The floating-point environment is set up at the start of the
> program by the C runtime, and compilers generate code that expects this
> environment to be untouched.
Okay, I think I understand it all, thanks. Are you planning to do
something to the docs in response to all this?
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk