# Definition:Modulo Operation

## Definition

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

Then the modulo operation is defined and denoted as:

$x \bmod y := \begin{cases} x - y \floor {\dfrac x y} & : y \ne 0 \\ x & : y = 0 \end{cases}$

where $\floor {\, \cdot \,}$ denotes the floor function.

### Modulo 0

We see that, from the definition:

$\forall x \in \R: x \bmod 0 = x$

This can be considered as a special case of the modulo operation, 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)$

## Examples

### Modulo Operation: $5 \bmod 3$

$5 \bmod 3 = 2$

### Modulo Operation: $18 \bmod 3$

$18 \bmod 3 = 0$

### Modulo Operation: $-2 \bmod 3$

$-2 \bmod 3 = 1$

### Modulo Operation: $100 \bmod 3$

$100 \bmod 3 = 1$

### Modulo Operation: $100 \bmod 7$

$100 \bmod 7 = 2$

### Modulo Operation: $-100 \bmod 7$

$-100 \bmod 7 = 5$

### Modulo Operation: $-100 \bmod 0$

$-100 \bmod 0 = -100$

### Modulo Operation: $5 \bmod -3$

$5 \bmod -3 = 5$

### Modulo Operation: $18 \bmod -3$

$18 \bmod -3 = 0$

### Modulo Operation: $-2 \bmod -3$

$-2 \bmod -3 = -2$

### Modulo Operation: $1 \cdotp 1 \bmod 1$

$1 \cdotp 1 \bmod 1 = 0 \cdotp 1$

### Modulo Operation: $0 \cdotp 11 \bmod 0 \cdotp 1$

$0 \cdotp 11 \bmod 0 \cdotp 1 = 0 \cdotp 01$

### Modulo Operation: $0 \cdotp 11 \bmod -0 \cdotp 1$

$0 \cdotp 11 \bmod -0 \cdotp 1 = -0 \cdotp 09$

### Modulo Operation: $x \bmod 3 = 2$ and $x \bmod 5 = 3$

Let $x \bmod 3 = 2$ and $x \bmod 5 = 3$.

Then:

$x \bmod 15 = 8$