Why 9 mod -7 = -5? Quotient and remainder with negative integers. Forgive me if this question does not belong on this site for it is simplistic and this is my first post, however I do not seem to understand the modulo function when it comes to negative numbers.
I'd assume the process for calculating modulo would be the same as with positive numbers:


*

*9 % 7 = 2 because 9 - (7 * 9/7) = 9 - (7 * 1) = 2


So wouldn't 9 % (-7) = 9 - (-7 * -9/7) = 9 - (-7 * -1) = 2?

Recall that $a \equiv b \bmod n$ if and only if $n$ divides $a - b$. This is the definition.
So is it true that $-5 \equiv 9 \bmod -7$?   
