Differences in results when using the same function in CTFE and Runtime

Timon Gehr timon.gehr at gmx.ch
Thu Aug 15 11:10:51 UTC 2024


On 8/15/24 12:25, Dom DiSc wrote:
> Also relying on specific inaccuracy of FP calculations is very bad design.

Personally I mostly care about reproducibility, but also, as I said 
earlier, accuracy-improving algorithms like Kahan summation or general 
double-double computations very much "rely on specific inaccuracy". It's 
not bad design, it may just be that you are not sufficiently informed 
about this kind of thing.

Kahan summation is even in Phobos: 
https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d#L7558-L7572

This implementation is however technically incorrect because D could 
choose a bad subset of the computations and run only those at "higher" 
precision, destroying the overall accuracy.

It gets more obvious if you drop the judgmental tone and just call 
"specific inaccuracy" by the proper name: "correct rounding".


More information about the Digitalmars-d mailing list