[testsuite gfortran] partial fix for secnds*.f
Tim Prince
tprince@myrealbox.com
Mon May 28 20:56:00 GMT 2007
Tobias Schlüter wrote:
> Thomas Koenig wrote:
>> On Mon, 2007-05-28 at 15:28 +0200, Dominique Dhumieres wrote:
>>> Why is it so difficult to see the obvious?
>>> - dat1 = 0.001*real (values(8)) + real (values(7)) +
>>> - & 60.0*real (values(6)) + 3600.0* real (values(5))
>>> + dat1 = 3600.0* real (values(5)) + 60.0*real (values(6)) +
>>> + & real (values(7)) + 0.001*real (values(8))
>>
>> Ouch. Yes, that can make a difference.
>>
>> However... as a general rule, I've learned that it is better to add real
>> values from small to big (less loss of precision that way). Would it
>> make more sense to change the order of terms in the secnds intrinsic?
>
> I think we should use parentheses to enforce the order. Not that the
> compiler reorders in its current incarnation, but it might at some
> point. I don't know of a way to enforce an order of evaluation in C
> besides separating the addition into a series of statements or using
> volatile.
Observance of parentheses is a requirement in the C90 and C99 standards,
as it always was in Fortran. According to my understanding, gcc doesn't
break this part of the standard, even with -ffast-math.
More information about the Fortran
mailing list