note
jepri
Actually, if I recall my number theory classes correctly, the <i>intent</i> of the modulus operator (<code>x mod y</code>) is to return the smallest number possible by repeatedly subtracting y from x.<P>
The shortcut is to divide x by y, but not all modular sets support a division operator - the natural numbers, for instance. In these cases, you have to go with the original definition. Since <code>x - 0 - 0 - 0 - 0 - 0...</code> is clearly x, <code> x mod 0 = x</code> is the correct answer. <P>
People care what Knuth says about math, because he was a mathematician. Mathematicians are notoriously 'tight' about definitions, so if Knuth said that <code>x mod 0</code> should return x then he had a good reason for it - one that might take some advanced math to explain.<P>
Incidentally a 'mapping' is the mathematical term given to an algorithm, very similar to what a perl programmer would think of as a function. It is a collection of rules that turns one set of numbers into another set of numbers. The perl function [map] is very similar in spirit to the mathematical map, except that (I don't think) it can generate new array elements for a one-to-many mapping.<P>
There is often a 'null' map - a function that leaves the original set untouched. This is important for a number of reasons that may strike you as silly<P>
All these ideas are covered in very rigorous detail in any book that has 'Number Theory' in the title.
<p>____________________<BR>
Jeremy<BR>
I didn't believe in evil until I dated it.
87384
87809