D float types operations vs C++ ones
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Dec 18 11:17:41 PST 2015
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 = __tmp0+__tmp1;
>>> a = __tmp2 + e;
>>> OR
>>> float __tmp2 = __tmp0+e;
>>> a = __tmp2+__tmp1;
>>
>> I see, thanks to all!
>
> I don't think this can be right, unless you use some kind of fast-math
> optimizer.
>
> But:
>
> Modern C++ compilers try to support ieee754-2008, which is needed to get
> reproducible results. D is based on the older 1985 version, and there is
> no announced effort to make it modern.
>
Thank you for the reference. If the Wikipedia article is precise in
language, it is just a recommendation:
"Clause 10: Expression evaluation
This clause is new; it recommends how language standards should specify
the semantics of sequences of operations, and points out the subtleties
of literal meanings and optimizations that change the value of a result."
https://en.wikipedia.org/wiki/IEEE_754_revision#Clause_10:_Expression_evaluation
Ali
More information about the Digitalmars-d-learn
mailing list