Re: D float types operations vs C++ ones

2015-12-18 Thread Ola Fosheim Gr via Digitalmars-d-learn
On Friday, 18 December 2015 at 07:30:52 UTC, drug wrote: What I mean about order of operations is that if you go a = b*a+c*c + e; the compiler is free to rewrite that as float __tmp0 = a*b; float __tmp1 = c*c; and then do either of float __tmp2 = __tmp0+__tmp1; a = __tmp2 + e; OR float __tmp2

Re: D float types operations vs C++ ones

2015-12-18 Thread Ali Çehreli via Digitalmars-d-learn
On 12/18/2015 12:19 AM, Ola Fosheim Gr wrote: On Friday, 18 December 2015 at 07:30:52 UTC, drug wrote: What I mean about order of operations is that if you go a = b*a+c*c + e; the compiler is free to rewrite that as float __tmp0 = a*b; float __tmp1 = c*c; and then do either of float __tmp2 =

Re: D float types operations vs C++ ones

2015-12-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 17 December 2015 at 11:58:35 UTC, drug wrote: On 17.12.2015 14:52, Andrea Fontana wrote: You should publish some code to check... Too much code to public - operations are simple, but there are many branches and reducing may take much time . In fact I asked to understand _in

Re: D float types operations vs C++ ones

2015-12-17 Thread drug via Digitalmars-d-learn
On 17.12.2015 16:09, Nicholas Wilson wrote: Yes the float types are the same. floats doubles are identical long double == real ( at least for x86) The only difference is that float are default initialised to NaN in D. The sources of difference are likely to occur from - const folding (varying

Re: D float types operations vs C++ ones

2015-12-17 Thread anonymous via Digitalmars-d-learn
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).

Re: D float types operations vs C++ ones

2015-12-17 Thread Ali Çehreli via Digitalmars-d-learn
On 12/17/2015 03:50 AM, drug wrote: > D and C++ [...] But with some data the results differ You may have similar results between two C and two C++ compilers, even between two different versions of the same compiler. In addition to possible reasons that has already been mentioned, note that

Re: D float types operations vs C++ ones

2015-12-17 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 17 December 2015 at 11:50:02 UTC, 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

Re: D float types operations vs C++ ones

2015-12-17 Thread drug via Digitalmars-d-learn
On 18.12.2015 05:58, Nicholas Wilson wrote: On Thursday, 17 December 2015 at 13:30:11 UTC, drug wrote: On 17.12.2015 16:09, Nicholas Wilson wrote: [...] Thanks for answer. My C++ version is tracing D version so commutativity and distributivity aren't requred because order of operations is the

Re: D float types operations vs C++ ones

2015-12-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 17 December 2015 at 13:30:11 UTC, drug wrote: On 17.12.2015 16:09, Nicholas Wilson wrote: [...] Thanks for answer. My C++ version is tracing D version so commutativity and distributivity aren't requred because order of operations is the same (I guess so at least), so I hoped for

D float types operations vs C++ ones

2015-12-17 Thread drug via Digitalmars-d-learn
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

Re: D float types operations vs C++ ones

2015-12-17 Thread drug via Digitalmars-d-learn
On 17.12.2015 14:52, Andrea Fontana wrote: You should publish some code to check... Too much code to public - operations are simple, but there are many branches and reducing may take much time . In fact I asked to understand _in general_ if it worth diving into code to find the source of the