Notation for modulo: congruence relation vs operator

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.