When the RHS expression of a mixed type assignment statement has been evaluated it has a specific type, this type must then be converted to fit in with the LHS. This conversion could be either a promotion or a relegation. For example,
The RHS needs relegating to be an INTEGER value. The right hand side is evaluated and then the value is truncated (all the decimal places lopped off) then assigned to the LHS.
The INTEGER needs promoting to become a REAL. The right hand side expression is simply stored (approximately) in the LHS.
For example, as real values are stored approximately,
REAL :: a = 1.1, b = 0.1 INTEGER :: i, j, k i = 3.9 ! i will be 3 j = -0.9 ! j will be 0 k = a - b ! k will be 1 or 0 a = j ! a will be about 1.0 or 0.0
Notes:
Care must be taken when mixing types!
Return to corresponding overview page