21 ms·
IMHO I think the problem here is that most people focus on the "wrong side" of 1/0. I mean, what the mathematical definition of division says is not that 1/0 i
by genezeta 8y ago
IMHO I think the problem here is that most people focus on the "wrong side" of 1/0.
I mean, what the mathematical definition of division says is not that 1/0 is indeed something and that that something is "undefined" or "NaN" or anything else really. What it says is "I cannot do 1/0, the division operation a/b does not apply when b is 0".
So 1/0 is not a thing in itself in mathematics; it's something which cannot be operated.
Now, back some time ago, "division by zero" simply threw an error. It signaled "this is not something that can be done". undefined, NaN, anything else, including 0, is not really something that has a mathematical justification. It's merely a practical approach to encapsulate that error into some form of pseudo-value to control it to some extent.
Personally, I don't really see how 1/0 = 0 is better than 1/0 = NaN or "undefined" or "Infinity".
- scj 8y agoThe practical downside is that it might make equations go slightly wonky, rather than completely wonky if a non-number is returned. For example, say if a zero divide happens with normalized values. Meaning the immediate result is only off by one at most. Odds of catching that are probably low. Meanwhile, a NaN will infect all numbers that come into contact with it, bubbling up faster... Under this system, programs are easier to debug if they use bigger numbers... That property does not seem like a win to me. If I attempt to open a file, but an access fault occurs, I'd rather be told the fault and given a chance to recover than receive an empty file.
- genezeta 8y agoI agree with that; in general I'd rather be told too. But I don't know anything about Pony or it's goals. So it may be preferable for them, I don't know.
- PyroLagus 8y agoExcept that 0 could actually be the result of a valid computation. NaN, undefined, or Infinity can not.
- genezeta 8y agoAnd you mean that as saying that it is then better? Or that it is not? (Sorry, I'm not sure which way you mean it)
- Izkata 8y agoIt seems straightforwardly better to me, because the programmer/user gets an immediate "you messed up" signal, instead of silently returning the wrong values until someone eventually (hopefully) notices.