0

I found this paper http://cmph.sourceforge.net/papers/chm92.pdf

and on page 7 in the last paragraph it shows a series of calculations where one is for example $$(4-7) \mod 12 = 9$$ But when I work this out I get $-3$

and so does the calculator. Is there something about mod I am misunderstanding in this use case? Or is there an error in that part of the paper

2 Answers2

2

An integer $m$ is congruent to $9 \mod 12$ if and only if $m-9$ is divisible by $12$. In this case, $m=7-4=-3$. Since $-3-9=-12$ is divisible by $12$, the result in the paper holds.

TomGrubb
  • 12,909
  • 1
    The imprecision in the answer will likely increase the confusion between mod as an operator vs. relation. – Bill Dubuque Feb 16 '17 at 22:48
  • This makes sense, I used my calculator on windows to do the calculation -3 %12 and it gave me the answer -3. Do I need to set my calculator to another setting? – user1016950 Feb 16 '17 at 22:49
  • @user1016950 how about you turn off your calculator and just think about the answer? Trust me, maths is much more beautiful (and, sometimes, easy) without calculators ;) – John Feb 16 '17 at 23:06
  • @user1016950: the meaning of the operation mod or % is not universally agreed when negative operands are involved. – Rob Arthan Feb 16 '17 at 23:06
1

In mathematics, we don't usually use the symbol $\mathrm{mod}$ as an operator but rather as as a way of writing a relation: $$ x \equiv y \mod n $$

means $x$ is equivalent to $y$ modulo $n$, i.e., it means that the difference $x - y$ is a multiple of $n$, or equivalently that $x$ and $y$ leave the same remainder when you divide them by $n$.

In programming and computer science $\mathrm{mod}$ is often used as an operator:

$$ y \mathop{\mathrm{mod}} n $$

means the remainder when you divide $y$ by $n$, subject to some convention for deciding whether a non-zero remainder should be positive or negative if one or both of $y$ and $n$ is negative. (Different programming languages differ on what this convention should be.)

The authors of the paper you are reading are adopting a convention that makes $-3 \mathop{\mathrm{mod}} 12$ positive.

Rob Arthan
  • 48,577