Ask Slashdot: What's the Harm In a Default Setting For Div By Zero?
New submitter CodeInspired writes: After 20 years of programming, I've decided I'm tired of checking for div by zero. Would there be any serious harm in allowing a system wide setting that said div by zero simply equals zero? Maybe it exists already, not sure. But I run into it all the time in every language I've worked with. Does anyone want their div by zero errors to result in anything other than zero?
Hi SlashDot. I'm a programmer who is tired of sanitizing inputs and checking for exceptions. Can you suggest a way to change the world so those things don't exist?
~~~~~~~
"You are not remembered for doing what is expected of you." - Atul Chitnis
Didn't you hear? Slashdot is trying this cutting-edge "Agile Development" thing. The idea is that instead of testing your changes, you just make them directly on your production site and see what happens. It's the wave of the future!
How can we continue to believe in a just universe and freedom to eat crackers if we have no ale?
Good thing you're pushing untested code into production, Dice!
Well, you see, they had this divide by zero error ...
Does anyone want their div by zero errors to result in anything other than zero?
Yes.
No.
Maybe.
100.0 / 0 = 3
402350.32302 / 0 = 3
pi / 0 = infinity
1942 / 0 = 0
194.3 / 0 = 0
101 / 0 = 1
1010 / 0 = 2
200.02 / 0 = 3
4004004 / 0 = 4
Somebody please submit a RFP for this to C++17 standards committee.
the preceding comment is my own and in no way reflects the opinion of the Joint Chiefs of Staff
He could be a mySQL programmer.
... for extremely large values of 2.
While you are making changes ....
Have gnu, will travel.
"Can't I just be a programmer and not understand math?"
caused by dividing by zero returning zero.
0/0 should be 1
Right, I don't even... ehh... totally confused. It's not aprils fools right? Did this article get approved just to mock the submitter, or has Slashdot gone totally of the rails?
Well, Slashdot recently implemented a new engine for approving articles, but there was a place in the code where one could end up dividing by zero, and they just decided to arbitrarily set that value to "post a random nonsensical Ask Slashdot question."
So, Timothy screwed something up... and, well, rather than throwing up an exception -- VOILA... this story was approved!
I'm surprised you haven't noticed this before -- I think it's how most "Ask Slashdot" questions get posted these days.