What is the modulos anyway? I have used this operator (%) only twice before and I didn’t quite understand it either time. All I knew is that it was doing what I hoped it would. I figured I should probably know what the modulus operator does so I called on the mighty name of Google and voila!:
The easiest explanation I found so far can be found at
Mote Interactive. For some interesting uses, check out Grant Skinner’s post on the matter. And finally, if all you’re looking to do is figure out odds or evens, Keith Peters found a nice post on an alternative to modulos.
I love Google.
[update]: Well, this wasn’t so helpful was it? Looks like the primary link is dead, so to better understand what modulo is: The remainder of expression 1 divided by expression 2. In plain english: if you have something like 12 % 5, the returned value is 2. Five goes into 12 twice, and the remainder is 2.