next up previous contents
Next: Integer Division Up: Mixing Objects of Different Previous: Mixed Numeric Type Expressions

 

Mixed Type Assignment

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,

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 gif


next up previous contents
Next: Integer Division Up: Mixing Objects of Different Previous: Mixed Numeric Type Expressions

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.