Data type of an arithmetic expression

Because the identity and negation operators operate on a single operand, the type of the resulting value is the same as the type of the operand.

The following table indicates the resulting type when an arithmetic operator acts on a pair of operands.

Notation: T(param), where T is the data type (I: integer, R: real, X: complex) and param is the kind type parameter.
Table 1. Result types for binary arithmetic operators
first operand second operand
I(1) I(2) I(4) I(8) R(4) R(8) R(16) X(4) X(8) X(16)
I(1) I(1) I(2) I(4) I(8) R(4) R(8) R(16) X(4) X(8) X(16)
I(2) I(2) I(2) I(4) I(8) R(4) R(8) R(16) X(4) X(8) X(16)
I(4) I(4) I(4) I(4) I(8) R(4) R(8) R(16) X(4) X(8) X(16)
I(8) I(8) I(8) I(8) I(8) R(4) R(8) R(16) X(4) X(8) X(16)
R(4) R(4) R(4) R(4) R(4) R(4) R(8) R(16) X(4) X(8) X(16)
R(8) R(8) R(8) R(8) R(8) R(8) R(8) R(16) X(8) X(8) X(16)
R(16) R(16) R(16) R(16) R(16) R(16) R(16) R(16) X(16) X(16) X(16)
X(4) X(4) X(4) X(4) X(4) X(4) X(8) X(16) X(4) X(8) X(16)
X(8) X(8) X(8) X(8) X(8) X(8) X(8) X(16) X(8) X(8) X(16)
X(16) X(16) X(16) X(16) X(16) X(16) X(16) X(16) X(16) X(16) X(16)
Note: IBM extension begins
  1. XL Fortran implements integer operations using INTEGER(4) arithmetic, or INTEGER(8) arithmetic if data items are 8 bytes in length. If the intermediate result is used in a context requiring INTEGER(1) or INTEGER(2) data type, it is converted as required.
         INTEGER(2) I2_1, I2_2, I2_RESULT
         INTEGER(4) I4
         I2_1 = 32767             ! Maximum I(2)
         I2_2 = 32767             ! Maximum I(2)
         I4 = I2_1 + I2_2
         PRINT *, "I4=", I4       ! Prints I4=-2
    
         I2_RESULT = I2_1 + I2_2  ! Assignment to I(2) variable
         I4 = I2_RESULT           ! and then assigned to an I(4)
         PRINT *, "I4=", I4       ! Prints I4=-2
         END
    IBM extension ends