Division by zero is undefined in any programming language (not just Perl)
Although this is perfectly true, the underlying truth is that division by zero is mathematically undefinable.
| [reply] |
That's not quite true, actually. Division by zero is impossible -- that is to say, zero does not have a multiplicative inverse -- in any field or indeed any ring, but general rings can have zero divisors (i.e., there may be a non-zero element a for which there exists a non-zero element b such that ab = 0).
If n is a composite number, then the quotient ring Z/nZ (basically the same as the integers, but with addition and multiplication carried out mod n) is an easy and natural example. Suppose that n = p * q for some p and q; [p] and [q] are elements of this ring, but since we're multiplying mod n, we've got [p] * [q] = [n] = [0].
| [reply] |
Agreed, if we redefine multiplication and division to mean something else than their common meaning, and also have them operate on objects that are not the common numbers, then many strange things can happen. Just as redefining white as a special shade of black might lead to embarrassing paradoxes. Don"t get me wrong, I know that mathematicians commonly "overload" the basic operators to mean something else than the common sense operations, and they have good natural reasons to do so.
But within the context we are really talking about, i.e. common arithmetic multiplication and division between natural, relative, rational, algebraic, transcendental, real or complex numbers, division by zero is mathematically impossible and even inconceivable. And the same goes for integers and floating-point numbers in CS.
I made the point that a division by 0 is mathematically impossible (Ok, granted, within the framework of the previous paragraph), because I feel this is a much more general and profound statement than just saying that it is not possible with all known programming language, which could be construed to mean that existing languages all have this limitation. This is not a language limitation, this is something which has been proven to be mathematically impossible. In other words, a very bold statement that it not only so, but will forever be so.
| [reply] |