C Tricks Modulo Bounds Checking
Writing a circular buffer in a language such as C will often include code which looks like the following:
The mathematical modulo operator is usually used to bound the range of output from a random number generator. The same principle can be applied to our circular buffer for much more elegant code.