next up previous contents
Next: Intrinsic Procedures Up: Mixing Objects of Different Previous: Mixed Type Assignment

 

Integer Division

Confusion often arises about integer division; in short, division of two integers produces an integer result by truncation (towards zero). Consider,

    REAL :: a, b, c, d, e
    a = 1999/1000             ! LHS is 1
    b = -1999/1000            ! LHS is -1
    c = (1999+1)/1000         ! LHS is 2
    d = 1999.0/1000           ! LHS is 1.999
    e = 1999/1000.0           ! LHS is 1.999

Great care must be taken when using mixed type arithmetic.

For more information, click here gif

Now try this question gif


next up previous contents
Next: Intrinsic Procedures Up: Mixing Objects of Different Previous: Mixed Type Assignment

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