Modulus Operator

The modulus operator returns the remainder of dividing the first expression by the second expression. For example, mod can be thought of performing the divided by and returning the remainder of the operation as shown in the expression below.

The modulus operator and more generally, modular arithmetic, is used throughout computing and mathematics when working with discrete numbers. A common application of the modulus operator and its way of thinking can be found in how humans represent time.

Modulo 3 Examples

Shown below are some basic examples of the operator where the right-hand expression is the discrete number .