Definition:Modulo Operation

Definition
Let $x, y \in \R$ be real numbers.

Then the operation $\bmod$ is defined as:
 * $x \bmod y := \begin{cases}

x - y \left \lfloor {\dfrac x y}\right \rfloor & : y \ne 0 \\ x & : y = 0 \end{cases}$

From the definition of the floor function, we see that, when $y \ne 0$:


 * $\displaystyle 0 \le \frac x y - \left \lfloor {\frac x y}\right \rfloor = \frac {x \bmod y} y < 1$.

Hence:
 * $y > 0 \implies 0 \le x \bmod y < y$
 * $y < 0 \implies 0 \ge x \bmod y > y$
 * $x - \left({x \bmod y}\right)$ is an integral multiple of $y$.

The operation is most usually defined when $x$ and $y$ are both integers.

From the Quotient-Remainder Theorem it follows that the quantity $x \bmod y$ is called the remainder when $x$ is divided by $y$. This still holds when $x$ and $y$ are not actually integers.

The value $\left \lfloor {\dfrac x y}\right \rfloor$ is called the quotient.

Modulo Zero
We see that, from the definition:
 * $x \bmod 0 = x$

This can be considered as a special case, but it is interesting to note that most of the results concerning the modulo operation still hold.

Modulo 1
Note also that from the definition:
 * $x \bmod 1 = x - \left \lfloor {x}\right \rfloor$

from which it follows directly that:
 * $x = \left \lfloor {x}\right \rfloor + \left({x \bmod 1}\right)$

The value $x \bmod 1$ is called the fractional part of $x$, and sometimes denoted $\left\{{x}\right\}$.

From Real Number Minus Floor we confirm that $0 \le x \bmod 1 < 1$.

Also see
Compare with congruence modulo $z$ which approaches the subject from a slightly different direction.