next up previous contents
Next: Related Work Up: Review of Key Background Previous: Frequency Ratios as Doublings

Modulo and Integer Division

Modulo and integer division are infix binary operators indicated by `$\bmod$' and `$\div$' respectively. Though their operands are usually integers, they can be real as well. (Integer division is ``integer'' only in the sense that its result is an integer.) The `$\bmod$' and `$\div$' operators are defined as follows.
\begin{align*}
x \div y & = \lfloor x/y \rfloor \\  x \bmod y & = x - y \lfloor x/y \rfloor\end{align*}
(The ``floor'' of x, $\lfloor x \rfloor$, is the maximum integer i such that i<x.)

Here we will present some examples of these operators applied to integer operands. For positive n, if n/k is represented in mixed-fraction form as i + j/k, $n \div k=i$ and $n \bmod k =
j$. For example, 10/7 = 1 + 3/7, which means that $10 \div 7 = 1$and $10 \bmod 7 = 3$. A slightly tricky thing about `$\bmod$' and `$\div$' is how they behave when n is negative. For example, one might think of (-3)/7 as 0 + -3/7, but, for the purposes of modulo and integer division, it should be thought of as -1 + 4/7. In other words, the integer part, not the remainder, must carry the sign. So $(-3) \div 7 = -1$ and $(-3) \bmod 7 = 4$.



Ben Denckla
8/29/1997