FORTRAN 77 Language Reference

Basic Arithmetic Expressions

Each arithmetic operator is shown in its basic expression in the following table:

Table 3-2 Arithmetic Expressions

Expression  

Meaning  

a ** z

a / z

a * z

a - z

-z

a + z

+z

Raise a to the power z

Divide a by z

Multiply a by z

Subtract z from a

Negate z

Add z to a

Same as z

In the absence of parentheses, if there is more than one operator in an expression, then the operators are applied in the order of precedence. With one exception, if the operators are of equal precedence, they are applied left to right.

Table 3-3 Arithmetic Operator Precedence

Operator  

Precedence  

**

* /

+ -

  First Second Last

For the left-to-right rule, the one exception is shown by the following example:


F ** S ** Z

The above is evaluated as


F ** (S ** Z)

:

f77 allows two successive operators. @

Example: Two successive operators:


	X ** -A * Z 

The above expression is evaluated as follows:


	X ** (-(A * Z))

In the above example, the compiler starts to evaluate the **, but it needs to know what power to raise X to; so it looks at the rest of the expression and must choose between - and *. It first does the *, then the -, then the **.