[testsuite gfortran] partial fix for secnds*.f

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Mon May 28 18:18:00 GMT 2007


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.

- Tobi



More information about the Fortran mailing list