This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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] | |
Thomas Koenig wrote: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.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.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |