accuracy of floating point calculations: d vs cpp

Timon Gehr timon.gehr at gmx.ch
Tue Jul 23 03:48:06 UTC 2019


On 22.07.19 14:49, drug wrote:
> I have almost identical (I believe it at least) implementation (D and 
> C++) of the same algorithm that uses Kalman filtering. These 
> implementations though show different results (least significant 
> digits). Before I start investigating I would like to ask if this issue 
> (different results of floating points calculation for D and C++) is well 
> known? May be I can read something about that in web? Does D 
> implementation of floating point types is different than the one of C++?
> 
> Most of all I'm interesting in equal results to ease comparing outputs 
> of both implementations between each other. The accuracy itself is 
> enough in my case, but this difference is annoying in some cases.

This is probably not your problem, but it may be good to know anyway: D 
allows compilers to perform arbitrary "enhancement" of floating-point 
precision for parts of the computation, including those performed at 
compile time. I think this is stupid, but I haven't been able to 
convince Walter.


More information about the Digitalmars-d-learn mailing list