|
|
|
|
|
by JonChesterfield
702 days ago
|
|
Zero is a fine answer for integer division by zero. "Oh noes you can't do that math, my teacher told me so in a school" isn't a brilliant heuristic to work from. How about modulo zero? That can be completely correctly define or a floating point exception if you decided to define it in terms of divide and also decided divide should do that. What about floating point? It gave up on reflexive equality and yet programs do things with doubles despite that. The integer divide zero industry best practice of promptly falling over isn't an axiom of reality. It's another design mistake from decades ago. |
|
It's not. Division (edit: of a positive integer) by zero is better approximated by +infinity rather than zero.
In real life to divide something into zero groups is nonsensical, thus the number system in programs should reflect this. In the exceptionally-rare case where you want to divide by zero and it makes sense (can't think of a scenario where that's true but let's stipulate), then you can use your language's equivalent of try/catch or (if (zerop x) ...) to get around it.
Don't fuck up normal mathematics for the rest of us just because some lazy programmer doesn't like to add error checking.