The C11 standard says:
6.5.5:6 When integers are divided, the result of the / operator is the algebraic quotient with any fractional part discarded.(105) If the quotient a/b is representable, the expression (a/b)*b + a%b shall equal a; otherwise, the behavior of both a/b and a%b is undefined.
with footnote 105:
105) This is often called ‘‘truncation toward zero’’.
Another way to define division is to round towards -oo. This is called Euclidean division. Python appears to use yet another definition, according to user3307862's link.
The %
operator, properly called “remainder”, is defined with respect to the corresponding division, so it either is always in [0..b) or in (-b..b) depending on the definition of /
.