3 ms·
Another thing to call out is that you also need to be precise in what the error is. Division by zero is indeed a grave error, but only when your code is not log
by omegalulw 5y ago
Another thing to call out is that you also need to be precise in what the error is. Division by zero is indeed a grave error, but only when your code is not logically thought out - there should never have been any codepaths that divide by zero in the first place. So the error that your should report is whatever cause the denominator to be zero, not division by zero. That's almost entirely useless, and
misleading.
- Jonathanks 5y agoYes, this. Parse all input at the application boundaries and reject invalid input. For division by zero, the code path that leads to that should encode the input as a number greater than zero. But this may be clunky to do, depending on the language you're working with.