Don Wrote:
> Paul D. Anderson wrote:
> > Does anyone have strong feelings for/against any of these options??
> >
> > Paul
>
> My opinion -- precision should be a per-object setting, since it is a
> property of the data. Rounding etc is a property of the operators and
> functions and should be thread-local, and set by creating a scope struct
> with a constructor that sets the mode to a new value, and a destructor
> which restores it to the previous one.
>
> eg
> BigFloat a = 5e50;
> BigFloat b = 1e-20;
> {
> BigFloatRounding(ROUND_DOWN); // applies until end of scope
> a*=sin(b);
> }
> // we're back in round-to-nearest.
>
I like that. I didn't consider scope as an option, but that's really what's
wanted now that you've pointed it out.
I agree that precision is part of the data, but it needs to be considered as
part of the operation as well. Multiplying two floats produces a number whose
potential precision is the sum of the operands' precision. We need a method to
determine what the precision of the product should be. Not that it's difficult
to come up with an answer -- but we have to agree on something. That's what the
context provides.
Thanks for your input.
Paul