This incident, together with the news that the 1997 film Titanic employed a Linux-based render farm to composite special effects shots together (one of the first such Linux deployments for a major Hollywood film), led to the Slashdot-era joke: "Linux renders ships. Windows renders ships useless."
Number divided by zero shall be zero. The possibly-floating-point exception of immediate program death is an interesting idea that has aged poorly. Loads of things go wrong in software. Div / 0 badly upsetting mechanical calculators isn't a reason for software to abort at the sight of it.
Counterarguments in comments perhaps. Someone have a driving passion for this particular edge case of missed input validation being wildly more important than all the others?
You could call it an incorrect answer if there was a correct answer to division by zero, but it's undefined instead with no correct answer. Sounds pedantic, but in math pedantic stuff matters, and apparently you can expand things to define division by zero as zero and not break math, https://www.hillelwayne.com/post/divide-by-zero/
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.
This is discussed in the article. The standard is to use infinity, not zero.
> A hardware example of exception handling is the IEEE 754 standard for floating point arithmetic which defines values for various exceptions (e.g. infinity for divide-by-zero)
I don't know if I per-se agree with defaulting to zero in all instances, but I agree with a somewhat general sentiment. Division by zero, it would be nice if it returned something we can count on. In my mind, I see it some pre-determined safe default value. Which in many cases, may be zero.
I think what I would like is perhaps a way to have something almost like an interrupt. And being able to set what the interrupt does or swap between different interrupts. At runtime we can see the denominator is zero, so trigger the interrupt. For a set of functions, I can set an interrupt where a divide by zero does return zero, these would be functions whose callers can safely handle the zero or perform some default state at zero. But other functions, maybe there is a different default value that callers can use and it not screw everything up.
Some may gripe about, but its a mathematically in correct answer. Sure, it is. But for systems, especially saftey critical systems, I'd rather know that in the event I didn't properly guard against a 0 in the denominator, a behavior that I can account for is guaranteed to happen (some safe default).
> I don't know if I per-se agree with defaulting to zero in all instances, but I agree with a somewhat general sentiment
I agree with this. Forcing every instance to be 0 might hide the issue as 0 could be a valid if unexpected result in situations which might make debugging more difficult. The same reason === is a thing. NaN seems plausible yet equally awkward. Null could work too
Sometimes, yes. One choice is the right and proper self flagellation and sorrow for poor behaviour. The other is to not disable the engines on your warship when a programmer missed an edge case.
Counterarguments in comments perhaps. Someone have a driving passion for this particular edge case of missed input validation being wildly more important than all the others?
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.
Deleted Comment
Division by zero returning a zero is a pretty bad and confusing result mathematically.
How about 5 - 8 = 0? Sensible result for the natural numbers.
X + 7? Surely you meant addition modulo 2^64.
What's the count leading zeros on zero? Is it zero, 64, random noise found in a register?
What's X shifted by word size? Zero? Minus one? X?
These are all choices. Some are familiar. But knowing integer divide zero is wrong is a tenant of faith.
> A hardware example of exception handling is the IEEE 754 standard for floating point arithmetic which defines values for various exceptions (e.g. infinity for divide-by-zero)
It's wrong.
How is infinity returned as a result anyway? It's not a number, and it's not <the largest number the computer can return> either.
I think what I would like is perhaps a way to have something almost like an interrupt. And being able to set what the interrupt does or swap between different interrupts. At runtime we can see the denominator is zero, so trigger the interrupt. For a set of functions, I can set an interrupt where a divide by zero does return zero, these would be functions whose callers can safely handle the zero or perform some default state at zero. But other functions, maybe there is a different default value that callers can use and it not screw everything up.
Some may gripe about, but its a mathematically in correct answer. Sure, it is. But for systems, especially saftey critical systems, I'd rather know that in the event I didn't properly guard against a 0 in the denominator, a behavior that I can account for is guaranteed to happen (some safe default).
I agree with this. Forcing every instance to be 0 might hide the issue as 0 could be a valid if unexpected result in situations which might make debugging more difficult. The same reason === is a thing. NaN seems plausible yet equally awkward. Null could work too
Oh. https://everydayastronaut.com/mars-climate-orbiter/
Dead Comment
Dead Comment