Arithmetic
An arith_primary is a primary of arithmetic type.
The following table shows the available arithmetic operators and the precedence each takes within an arithmetic expression.
| Arithmetic Operator | Representation | Precedence |
|---|---|---|
| ** | Exponentiation | First |
| * | Multiplication | Second |
| / | Division | Second |
| + | Addition or identity | Third |
| - | Subtraction or negation | Third |
IBM® Open XL
Fortran evaluates the terms from left to right
when evaluating an arithmetic expression containing two or more addition or subtraction operators.
For example, 2+3+4 is evaluated as (2+3)+4, although a processor
can interpret the expression in another way if it is mathematically equivalent and respects any
parentheses.
The factors are evaluated from left to right when evaluating a term containing two or more
multiplication or division operators. For example, 2*3*4 is evaluated as
(2*3)*4.
The primaries are combined from right to left when evaluating a factor containing two or more
exponentiation operators. For example, 2**3**4 is evaluated as
2**(3**4). (Again, mathematical equivalents are allowed.)
The precedence of the operators determines the order of evaluation when IBM Open XL
Fortran is evaluating an arithmetic expression
containing two or more operators having different precedence. For example, in the expression
-A**3, the exponentiation operator (**) has precedence over the
negation operator (-). Therefore, the operands of the exponentiation operator are
combined to form an expression that is used as the operand of the negation operator. Thus,
-A**3 is evaluated as -(A**3).
Note that expressions containing two consecutive arithmetic operators, such as A**-B or
A*-B, are not allowed. You can use expressions such as A**(-B) and
A*(-B).
If an expression specifies the division of an integer by an integer, the result is rounded to an
integer closer to zero. For example, (-7)/3 has the value -2.
For details of exception conditions that can arise during evaluation of
floating-point expressions, see Detecting and trapping floating-point
exceptions. 
