Common types of integer division:
T: Truncated (the quotient is truncated toward 0)
F: Floored (the quotient is floored toward -infinity)
E: Euclidean (the remainder is always positive)
C89 requires Truncated semantics for div(), but not for / and %.
C99 and newer require Truncated semantics for / and % (and for div() too).
T F E
33 / 5 6 6 6
33 % 5 3 3 3
-33 / 5 -6 -7 -7
-33 % 5 -3 2 2
33 / -5 -6 -7 -6
33 % -5 3 -2 3
-33 / -5 6 6 7
-33 % -5 -3 -3 2
T F E
30 / 5 6 6 6
30 % 5 0 0 0
-30 / 5 -6 -6 -6
-30 % 5 0 0 0
30 / -5 -6 -6 -6
30 % -5 0 0 0
-30 / -5 6 6 6
-30 % -5 0 0 0
T F E
0 / 5 0 0 0
0 % 5 0 0 0
0 / -5 0 0 0
0 % -5 0 0 0