Modular arithmetic

In modular arithmetic, numbers "wrap around" when they reach a certain value, called the modulus. Modular arithmetic is common in music, particularly modulo 12, due to the chromatic scale having twelve notes. This application uses modular arithmetic for many purposes, for example index modulation.

A familiar example of modular arithmetic is a digital clock: at midnight, the clock shows 00:00, and an hour later it changes from 00:59 to 01:00, because the seconds wrap around back to zero. In other words, seconds are modulo 60. For integers, the operation is equivalent to the remainder of division by the modulo, except that negative results are handled specially. The figure below shows modulo 3 for a range of input values.

xx mod 3
52
41
30
22
11
00
−12
−21
−30
−42
−51
−60