If a and b are congruent modulo a number c, we might write $a \equiv b \pmod c$. When writing programs, it's often useful to compute the remainder after division, and in pseudocode we might write a = b mod c, where mod is understood to be a a binary operator which assings a = b - c * floor(b / c).

When writing an academic paper, should any distinction be drawn between these two uses? Specifically, when describing how to compute a set of parameters, we are currently specifying many using imperative (how-to-compute, e.g., modulus-operator-like) syntax (and a few with the declarative, modular-congruence-like syntax). For instance, would this:

a = b + c / d
e = f (mod g)

Be better rendered as this:

a = b + c / d
e = f mod g

In formal writing? I tend to believe the latter is more appropriate, but this might be a folk belief.

EDIT: Also note that an "=" is currently being used. If we stick with the "mod" inside parentheses, should we be using "$\equiv$"?


There are two related concepts: the relation, and the operator. The operator is very common in Computer Science.

The relation notation corresponds to the binary relation on integers. $a\equiv b\pmod{n}$ (or $a=b\pmod{n}$; the former is more common, but there is nothing to stop you from using the latter) if and only if $n|b-a$.

In computer science, the modulo operator is common: specifically, $a\bmod n$ means "the remainder when dividing $a$ by $n$". In other words, $a\bmod n$ is the smallest positive integer $r$ such that $a\equiv r\pmod{n}$.

Formally, the two notations refer to two different things: one is a relation, one is an operator. You should certainly keep the distinction clear in a paper, in my humble opinion.

  • 2
    $\begingroup$ A humble opinion that I get to enforce from time to time as a referee, of course... (-; $\endgroup$ Jan 23 '12 at 16:59
  • $\begingroup$ That was my understanding as well, but it is reassuring to hear it from somebody with a reputation of almost 100k in the Math SE. So I should go with the second of the two examples in my post? $\endgroup$
    – Patrick87
    Jan 23 '12 at 17:00
  • 1
    $\begingroup$ @Patrick87: I would certainly prefer the second; however, it is never amiss to make explicit what may be confusing to some readers in a paper, so a quick parenthetical note the first time you use the notation that says something like "where $x\bmod y$ represents the nonnegative remainder when dividing $x$ by $y$" would not be amiss and would probably be welcomed by most readers. $\endgroup$ Jan 23 '12 at 17:01
  • $\begingroup$ OK, awesome. One last question. Would it be best just to write $e = f - g \cdot \left \lfloor f / g \right \rfloor$, to eliminate any confusion? Or would that be considered pedantic? $\endgroup$
    – Patrick87
    Jan 23 '12 at 17:06
  • $\begingroup$ @Patrick87: Personally, I think it's easier reading to write "$e = f\bmod g$, where $x\bmod y$ is the nonnegative remainder when dividing $x$ by $y$" (and omitting the explanation after the first time), than writing "$e = f-g\lfloor f/g\rfloor$", which is valid for non-integer values and which may take longer to process, even if it says the same thing. $\endgroup$ Jan 23 '12 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.