FORTRAN 77 Language Reference

### Rules

Note these rules for the data type of an expression:

• If there is more than one operator in an expression, then the type of the last operation performed becomes the type of the final value of the expression.

• Integer operators apply to only integer operands.

Example: An expression that evaluates to zero:

`	2/3 + 3/4 `

• When an INTEGER*8 operand is mixed with REAL*4 operands, the result is REAL*8.

There is one extension to this: a logical or byte operand in an arithmetic context is used as an integer.

• Real operators apply to only real operands, or to combinations of byte, logical, integer, and real operands. An integer operand mixed with a real operand is promoted to real; the fractional part of the new real number is zero. For example, if R is real, and I is integer, then R+I is real. However, (2/3)*4.0 is 0.

• Double precision operators apply to only double precision operands, and any operand of lower precision is promoted to double precision. The new least significant bits of the new double precision number are set to zero. Promoting a real operand does not increase the accuracy of the operand.

• Complex operators apply to only complex operands. Any integer operands are promoted to real, and they are then used as the real part of a complex operand, with the imaginary part set to zero.

• Numeric operations are allowed on logical variables. @ You can use a logical value any place where the FORTRAN Standard requires a numeric value. The numeric can be integer, real, complex, double precision, double complex, or real*16 (SPARC only). The compiler implicitly converts the logical to the appropriate numeric. If you use these features, your program may not be portable.

Example: Some combinations of both integer and logical types:

```	COMPLEX  C1 / ( 1.0, 2.0 ) /
INTEGER*2 I1, I2, I3
LOGICAL L1, L2, L3, L4, L5
REAL R1 / 1.0 /
DATA I1 / 8 /, I2 / 'W' /, I3 / 0 /
DATA L1/.TRUE./, L2/.TRUE./, L3/.TRUE./, L4/.TRUE./,
&		 L5/.TRUE./
L1 = L1 + 1
I2 = .NOT. I2
L2 = I1 .AND. I3
L3 = I1 .OR. I2
L4 = L4 + C1
L5 = L5 + R1```