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: GCC beaten by ICC in stupid trig test!


I wrote:

Dave Korn wrote:

 >   IIUIC the fact that the + operator is specified in the standard as
 > binding left-to-right imply that "a + b + c" with no brackets *has* to
 > be interpreted as "(a + b) + c".

No, it establishes the way the multi-operator expressions may be combined *for interpretation*. I.e., what the expression means (on a high level, before applying such rules as 1.4 (6) [This standard does not specify] ... the method of rounding, approximating or computing numeric values on a particular processor").

This might not be as clear as possible, because '+' happens to be associative in the REAL world.


What the Fortran standard wants to make clear is that a grouping is necessary to establish an interpretation for unparenthesized expressions with more than one operator.

The example with '+' is trivial, because '+' is associative in the real numbers, so a standard-enforced ordering is superfluous.

However, this is not true of '/' (division) or '**' (exponentiation). Therefore, the standard establishes that for division:

A / B / C means (A / B) / C and not A / (B / C)

and for exponentiation:

A ** B ** C means A ** (B ** C) and not (A ** B) ** C

Both interpretations follow mathematical practice, but still have to be defined for the standard.

Hope this helps,

--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://gcc.gnu.org/fortran/ (under construction)


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