On 17.12.2015 12:50, drug wrote:
I have two implementation of the same algorithm - D and C++ (that is
port of D version). I assume that running these implementations on the
same data should give the same results from both. But with some data the
results differ (5th decimal digit after point). For my purpose it isn't
important and I can ignore this difference. But I'd like to have the
same results totally (I mean bit to bit) to easy maintanence of the
implementations. Question is - can I rely that D and C++ float types
operations should give the same result because D and C are similar or no
and I should use more portable way and compare floats with some epsilon?

D explicitly allows compilers to use greater precision in calculations than the involved types have [1]. For example, an expression involving `float`s may be evaluated at double or real precision.

That means, you cannot rely on getting the same results even when looking only at D. Compiler A may produce higher precision code than compiler B; or machine X offers a larger maximum precision than machine Y (and the compiler makes use of it).


[1] http://dlang.org/spec/float.html

Reply via email to