1

When dealing with negative modulo such as

7 (mod -5) = -3

is it not necessary that remainder be less than divisor?

I thought modulo should always be positive but the calculator certainly

seem to have no problem with negative modulo.

Does the rules change when dealing with negative modulos?

1 Answers1

3

In number theory, "$\pmod n$" usually isn't an operation. It's most often part of $\equiv$. So, for instance, $5\equiv 2\pmod 3$ doesn't mean that if you apply a "modulus 3 operation" to $5$, you get $2$. It means that $5$ and $2$ are congruent modulo $3$. In other words, that they are some multiple of $3$ apart.

So there is no problem at all with saying $5\equiv 8\pmod 3$, or $5\equiv-4\pmod3$.

We also get that $\pmod n$ and $\pmod{{-}n}$ are equivalent, so we usually don't use negative modulus, because it doesn't give us anything at all.

As for the % (modulo) operator in programming languages, and on calculators, how they behave with negative numbers is partially up to whoever designed it. There are several equally correct ways to do it. Some may have opinions on which way is the "best", I personally haven't used them enough to make up my mind.

Bill Dubuque
  • 272,048
Arthur
  • 199,419
  • The binary operation $\bmod$ is also used in mathematics, e.g. $\ 10\bmod 9 = 1,,$ and that its likely what the OP intended. – Bill Dubuque Dec 16 '18 at 23:08
  • @BillDubuquque You may be right. I changed the wording slightly to be more correct. Although the binary operation with that notation is not used nearly as often as the relation version to my knowledge. Most of the time I see these kinds of questions on this site, it's due to misunderstanding the relation and thinking it's an operation. – Arthur Dec 16 '18 at 23:12
  • Often it is merely a misunderstanding of notation - as is likely here. – Bill Dubuque Dec 16 '18 at 23:21