The connection between quotient, remainder, modulo and floor functions motivates the following generalization of congruences:

Definition: Modulo Operation for Real Numbers

Using the definition of the floor function, we define for any two real numbers \(x,y\) with \(y\neq 0\) the modulo operation "\(\operatorname{mod}\)" as follows:

\[x\mod y:=x-y\cdot \left\lfloor \frac xy \right\rfloor.\]

This definition leaves the case \(y=0\) undefined, in order to avoid division by zero. For \(y=0\), we set1

\[x\mod 0:=x.\]

The number \(y\) after "\(\operatorname{mod}\)" is called the modulus.


In the following interactive figure you can study the graph of \(x\mod y\) by manipulating the value of \(y\):

Examples: 1

Thank you to the contributors under CC BY-SA 4.0!




  1. Graham L. Ronald, Knuth E. Donald, Patashnik Oren: "Concrete Mathematics", Addison-Wesley, 1994, 2nd Edition


  1. This convention preserves the property that \(x\operatorname{mod}y\) always differs from \(x\) by a multiple of \(y\).