FORTRAN Reference Manual

Expressions
FORTRAN Reference Manual528615-001
3-5
Determination of Result Type
The result of integer division is the signed, nonfractional part of the quotient. The
fractional part is truncated, not rounded. For example, the values of K after the
following assignments are 0:
K = 2/3 + 1/3 <-- = 0 + 0
K = -2/3 <-- = 0
Exponentiation entails additional restrictions. Table 3-3 shows the results when
operands of different types are combined in an exponential expression.
D1 D = D1 ~ DBLE(I2) D = D1 ~
DBLE(R2)
D = D1 ~ D2 Illegal
C1 C = C1 ~ CMPLX
(REAL(I2),0.)
C = C1 ~
CMPLX(R2,0.)
Illegal C = C1 ~ C2
REAL, DBLE, CMPLX are type-conversion functions as described in Section 8, Intrinsic Functions
~ is +, -, *, or /.
I = INTEGER, R = REAL, D = DOUBLE PRECISION, C = COMPLEX.
Table 3-3. Evaluation of Mixed-Type Exponential Expressions
Exponent
Base Integer Real Double Precision Complex
Integer Integer Real Double Precision Complex
Real Real Real Double Precision Complex
Double Precision Double Precision Double Precision Double Precision Illegal
Complex Complex Complex Illegal Complex
Negative type of base Illegal Illegal Complex
Table 3-2. Determination of Expression Type (page 2 of 2)
X2
x1 I2 R2 D2 C2