On Thursday, 19 May 2016 at 07:09:30 UTC, Walter Bright wrote:
On 5/18/2016 10:10 AM, Timon Gehr wrote:
double kahan(double[] arr){
double sum = 0.0;
double c = 0.0;
foreach(x;arr){
double y=x-c;
double y = roundToDouble(x - c);
double t=sum+y;
double t = roundToDouble(sum + y);
c = (t-sum)-y;
sum=t;
}
return sum;
}
Those are the only two points in the program that depend on
rounding. If you're implementing Kahan, you'd know that, so
there shouldn't be anything difficult about it.
There's no reason to make the rest of the program suffer
inaccuracies.
People are trying to get across that, if they wanted to maximize
accuracy, they would request the most precise type explicitly. D
has 'real' for that. This thread has shown unequivocally that the
semantics you are insisting on is bound to cause endless
confusion and complaints.