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