I get that Int rounds down for negative numbers, and I understand why
-0.625 - 1 * INT(-0.625/1) = .375
So if Mod is defined as <<MOD(n, d) = n - d*INT(n/d)>>, I get it. (And
it's damn handy for figuring the difference between two times spanning
midnight.)
But if Mod is defined as "Returns the remainder after number is
divided by divisor. The result has the same sign as divisor", then I
don't get it.
If 11 is divided by 3, the remainder is 2.
What is the remainder of -11 divided by 3 ?
What is the remainder of 11 divided by -3 ?
-11/3 = 11/-3 = -(11/3) !!!
Ok, I can see when I do the long division with either the divisor or
the dividend being negative I am either subtracting 9 from -11 (=-20)
or subtracting -9 from 11 (=20), which is different from the remainder
when both divisor and dividend are positive, 2 (or both negative, -2).
I guess I never knew what the "remainder" was when the divisor and
dividend were different signs. It somehow ends up being what the
remainder would have been if all was positive, added to the divisor,
the divisor keeping its sign, and the remainder keeping the sign of
the dividend. Let's see... Oh, that would be n - d*INT(n/d).
Ok, I'm done