News for hackers. Stuff that matters.
Re:1/0 = 0 by ifdefdebug on Friday August 10, 2018 @09:53PM (#17737866)
Most of the time when I have to think about what to do with a 0 divisor, I come to the conclusion that

  if (foo == 0):
    return MAX_FLOAT
  else:
    return bar / foo
is more sound for the given algorithm than "return 0" (still crappy, but more sound).

Then use MAX_FLOAT as an error flag instead of 0, which could have been the result of a legal operation (with bar==0).

There are no comments on this comment yet.