However, the real distinction lies in how the two operations handle negative dividends: If n is positive, the modulo operator
x mod n
always returns a number between 0 and n – 1. The remainder operator returns a number between –n + 1 and 0 if x is negative instead. For example, -17 mod 12 = 7
and -17 rem 12 = -5.
I have yet to see a case where the remainder operator is the one that you want. If a language only supports rem I find myself constantly writing (x rem n + n) rem n
(which is just x mod n).