When an integer denominator does not divide evenly into an integer
numerator, the division operator truncates, rather than rounds, the result,
producing another integer. The
modulus operator, %
, produces
the remainder:
5 / 3 /* Divide, evaluating to 1, rather than to 2 or 1.66667 */ 5 % 3 /* Divide, evaluating to the remainder, 2 */
Of course, when dividing floating-point numbers, C produces a floating-point result:
5.0 / 3.0 /* Divide, evaluating to 1.66667 */