FORTRAN Reference Manual
Expressions
FORTRAN Reference Manual—528615-001
3-4
Determination of Result Type
•
Example 2
•
Example 3
Determination of Result Type
FORTRAN determines the data type of an arithmetic expression according to the data
types of its operands.
If all the operands of an expression are the same type, the resulting value is also of
that type.
If operands of different types appear in an expression, the data type of the result is
determined by conversion rules that FORTRAN applies to the intermediate results
generated during the evaluation of the expression. Table 3-2 shows how FORTRAN
determines the type of an arithmetic expression involving two operands.
Table 3-2. Determination of Expression Type (page 1 of 2)
X2
x1 I2 R2 D2 C2
l1 I = I1 ~ I2 R = REAL(I1) ~ R2 D = DBLE(I1) ~ D2 C =
CMPLX(REAL(I1),0
. ~ C2
R1 R = R1 ~
(REAL(12)
R = R1 ~ R2 D = DBLE(R1) ~
D2
C = CMPLX(R1,0.)
~ C2
(5 + 3) (2 - 6)
*
(5 + 3) (2 - 6)
*
(2 - 6)
*
8-4
*
-32
VST0302.vsd
VST0303.vsd
2 ** 2 ** 3
2 ** 2 ** 3
2
**
8
256










