This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [testsuite gfortran] partial fix for secnds*.f


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]