There are two similar operations: modulo and remainder. Modulo represents a more mathematical usage, and remainder more IT usage.
Assume we have two integers, a and b.
MOD(a, b) will return a result which has the same sign as b.
REM(a, b) will return a result which has the same sign as a.
- this is what is implemented in C/C++/C# as the % operator and often confusingly called "mod"
You can think of it like this too:
MOD(a, b) will find the largest integer multiple of b (call it "c") that is smaller than a, and return (a - c).
e.g. MOD(-340,60) we find c = -360 is the largest multiple of 60 that is smaller than -340. So we do (-340 - (-360)) = 20.
REM(a, b) will return a value such that (DIV(a,b) * b) + REM(a, b) = a, where DIV() represents integer division.
So for r = REM(-340, 60)
-340 = DIV(-340,60) * 60 + r
= -5 * 60 + r
= r - 300
This solves to give us r = -40.