0
$\begingroup$

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

  • 1
    I'm sorry but $4-7=\color{red}-3\equiv 9\mod12$.2017-02-16
  • 0
    $4-7=-3$ and $-3+12=9$. How are you getting 3?2017-02-16
  • 0
    Yes, sorry I meant -3 not 32017-02-16
  • 1
    It's true that $4-7 = -3$, but mod 12 this is congruent to $-3 + 12 = 9.$2017-02-16

2 Answers 2

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.

  • 1
    The imprecision in the answer will likely increase the confusion between mod as an operator vs. relation.2017-02-16
  • 0
    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?2017-02-16
  • 0
    @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 ;)2017-02-16
  • 0
    @user1016950: the meaning of the operation mod or % is not universally agreed when negative operands are involved.2017-02-16
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.