# Negative modulo: why is $-3$ mod $12$ equal to $9$?

I know that in general, we can represent a number $x$ as follows:

$x = qn + r$

where $r$ is the remainder, $n$ is the divisor, and $q$ is the quotient.

But suppose we try to calculate $-3 \div12$. An answer elsewhere on Math StackExchange suggests that the answer is:

$-3 = -1 \times12+9$

In other words, that $-3 \mod 12 = 9$.

But can't we represent this as:

$-3 = -2 \times 12 + 21$

And get a different answer?

• Generally speaking, one requires the remainder, $r$, to satisfy $0≤r<n$. thus $21$ isn't an eligible remainder.
– lulu
Commented Jun 26, 2018 at 13:48
• A number with a remainder of $-3$ is equivalent to having a remainder of $9$. Try it with some sample numbers - $9,21,33$ etc. Commented Jun 26, 2018 at 13:50
• It's true that $-3\equiv 21 \bmod 12$. And that $-3\equiv 117 \bmod 12$. All of these numbers are in the same equivalence class. Typically the smallest non-negative value is used to represent the class. Commented Jun 26, 2018 at 13:51
• @Joffan That just made things a lot simpler to understand. If you make that an answer, I'll gladly accept. Thank you all for your help! Commented Jun 26, 2018 at 13:52
• Oh, wait, $21 mod 12$ is 9, not $-3$. Unless I misunderstood your notation. Commented Jun 26, 2018 at 13:54

It's true that $-3\equiv 21 \bmod 12$. And also that $-3\equiv 117 \bmod 12$, and and of course $-3\equiv 9 \bmod 12.$ All of these numbers are in the same congruence or residue class. Typically the smallest non-negative value is used to represent the class.

The general definition is that $$a\equiv b\bmod n \iff \text{n divides a-b}.$$ If you take $a=-3$, $b=9$ and $n=12$ you see that the definition is met.

"$x \mod 12$" is really a shorthand for the (infinite) set of numbers that are congruent to $x$ modulo 12. So

$-3 = 9 = 21 \mod 12$

because $-3, 9$ and $21$ are all members of the same congruence class modulo 12. In other words, their differences are all divisible by 12.

We could write this congruence class as $\{\dots,-15, -3, 9, 21, 33, \dots\}$ but that would become tedious so by convention we represent the congruence class by just one of its members, often the smallest non-negative member. So we represent $\{\dots,-15, -3, 9, 21, 33, \dots\}$ by $9 \mod 12$.

I think you’re overcomplicating it. It simply boils down to this:

$$b\equiv c\pmod m \iff \frac{b-c}{m}\in\Bbb Z$$

where $\Bbb Z$ contains negatives as well as positives.

Since $$\frac{-3-9}{12}=-1$$ we say $-3\equiv 9\pmod {12}$ or alternatively $-3\bmod 12 =9$.