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

 

Mixed Type Assignment

Problems often occur with mixed-type arithmetic; the rules for type conversion are given below.

For example,

    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

Note: as a and b stored approximately, the value of k is uncertain.

For more information, click here gif


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

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.