next up previous
Next: 6. Ordering in Common Up: Common Fortran Errors Previous: 4. Double Precision Constants

5. Integer Division.

If you divide an integer by an integer the compiler assumes you want integer division with remainders discarded.

(a) To ensure a real answer when dividing by an integer n, divide by 1.*n, or by real(n).

(b) This problem often occurs when the decimal point is accidentally omitted when dividing by a real constant (cf., Category 3 above).



Daniel Mitchell
1999-03-08