Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: On Arnold's challenge & Paul's Observation...



Kreinovich, Vladik wrote:
For example, as everyone know from numerical math, computing a+b+c also
depends on the order of the operations; some languages like C compute
left to right, Fortran if I remember correctly computes right to left,
and compilers change the order -- shall we prohibit this too?
Although the syntax rules in the Fortran standard are left associative for addition, subtraction, multiplication and division, and right associative for exponentiation, the standard does not in fact specify the order of operations.

According to subclause 7.1.5.2.4 (page 139) of the March 2008 draft of the Fortran 2008 standard (http://j3-fortran.org/doc/year/08/08-007r2.pdf):

   Once the interpretation of a numeric intrinsic operation is
   established, the processor may evaluate any mathematically
   equivalent expression, provided that the integrity of parentheses is
   not violated.


Exactly these words appeared in subclause 6.6.4 of the 1977 Fortran standard. I would not be surprised if the same words appeared in the 1966 Fortran standard.

The words were somewhat different in the 1966 standard:

   If mathematical use of operators is associative, commutative, or
   both, full use of these facts may be made to revise orders of
   combination, provided only that integrity of parenthesized
   expressions is not violated.

--
Van Snyder                    |  What fraction of Americans believe
Van.Snyder@xxxxxxxxxxxx       |  Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or
disapproved by JPL, CalTech, NASA, the President, or anybody else.