http://www.perlmonks.org?node_id=995640


in reply to Re: Re: Re: 0 illegal modulus?
in thread 0 illegal modulus?

You write: If you take a definition from a random hit for "modulo mathematical definition" taken from the WWW, for instance, you'll find the definition: Two numbers a and b are said to be equal or congruent modulo N iff N|(a-b), i.e. iff their difference is exactly divisible by N. Usually (and on this page) a,b, are nonnegative and N a positive integer. We write a = b (mod N). Note that the difference has to be divisible by N. Yes, and the difference between no two different integers is divisible by zero. Therefore all integers are in different congruence classes mod 0, which is another way of saying that x mod 0 = x, as the original poster claimed. Although of course it's a matter of definition whether (1) an integer is then congruent to itself mod 0 and (2) the mod "operator" is actually that closely related to the mod "arithmetic" that it returns the name of the congruence class under arithmetic mod that number. % is probably better called "remainder" than mod, anyhow, and again it makes sense for x % 0 to be x when you talk about remainders. No matter how often you subtract zero, x remains... (but that's the same argument others have made).