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 x - 0 - 0 - 0 - 0 - 0... is clearly x, x mod 0 = x is the correct answer.
People care what Knuth says about math, because he was a mathematician. Mathematicians are notoriously 'tight' about definitions, so if Knuth said that x mod 0 should return x then he had a good reason for it - one that might take some advanced math to explain.
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.
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
All these ideas are covered in very rigorous detail in any book that has 'Number Theory' in the title.
I didn't believe in evil until I dated it.
|Replies are listed 'Best First'.|
Re^3: 0 illegal modulus?
by Anonymous Monk on Jul 10, 2007 at 08:32 UTC
Re: Re: Re: 0 illegal modulus?
by mugwumpjism (Hermit) on Jun 15, 2001 at 00:20 UTC