Paul D. Anderson wrote:
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.

Yes, I guess you'd need to specify a maximum precision in the scope, as well. By the way, when I get around to adding rounding and exception control for the FPU in std.math, I propose to do it in this way as well, by default. The idea from C that the rounding mode can legally be changed at any time is ridiculous.


Thanks for your input.

Paul



Reply via email to