Readit News logoReadit News
bitwize · 2 years ago
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."
dylan604 · 2 years ago
What about Linux running on Pentium chips?
JonChesterfield · 2 years ago
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?

anlsh · 2 years ago
Your idea that your program should just spit out an incorrect answer when it runs into an unexpected condition? That's really stupid
rsaarelm · 2 years ago
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/
JonChesterfield · 2 years 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.

shrimp_emoji · 2 years ago
That's what humans do! Or, more generally, what neural networks do. :p And I agree: ideally, software would be more rational than that.
nkrisc · 2 years ago
What’s the correct answer to division by zero?

Deleted Comment

bee_rider · 2 years ago
I don’t remember if it is on by default or not, but there’s some mxcsr flag to make division by zero return an INF, I’m pretty sure.

Division by zero returning a zero is a pretty bad and confusing result mathematically.

JonChesterfield · 2 years ago
7 / 2 = 3 is similarly nonsense. It's just more familiar.

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.

8organicbits · 2 years 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)

foobar1962 · 2 years ago
> This is discussed in the article. The standard is to use infinity, not 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.

tcmart14 · 2 years ago
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).

dylan604 · 2 years ago
> 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

nemetroid · 2 years ago
Should we do the same for segmentation faults? Silently return zero and let the program continue with whatever broken internal state it ends up with?
JonChesterfield · 2 years ago
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.
hyperhello · 2 years ago
Decriminalize all operations!
lowbloodsugar · 2 years ago
Should have let NASA take care of it! They know all about keeping expensive systems around despite the math?

Oh. https://everydayastronaut.com/mars-climate-orbiter/

qingcharles · 2 years ago
The math was fine, the units were wrong :) (I just read the NASA report the other day to see what the root cause really was)
lowbloodsugar · 2 years ago
Knowing the units is math that you get graded on. The div0 problem was one of domain and range: also math.
ikekkdcjkfke · 2 years ago
Just return NaN or Infinity?
dylan604 · 2 years ago
how about returning a black hole since that's what happens when god divides by zero.

Dead Comment

Dead Comment