D float types operations vs C++ ones

drug via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 17 23:30:52 PST 2015


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 same (I guess so at least), so I hoped for bit to
>> bit equality (it simplifies comparing serialized data). But I found
>> that error between D and C++ versions grows if more data processed so
>> I should investigate it anyway.
>
> 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 = __tmp0+e;
> a = __tmp2+__tmp1;

I see, thanks to all!


More information about the Digitalmars-d-learn mailing list