7

When I was learning to program nearly 15 my years ago I was incorrectly lead to believe that dividing by zero would be a much more common problem.

Comments
  • 1
    Much more common because many idiots write such code and many reviewers are too lazy to review
  • 4
    It is only a common problem in code containing divisions. In code not containing divisions, division by zero doesn't happen too often.
  • 1
    Yeah floating point numbers don't work so you never divide by Ero and get a larger number

    *Waits for the hate*
  • 1
    Honestly, I can't even remember the last time I properly divided something full stop
  • 1
    Index out of range

    Object is null

    Are probably my top 2.
  • 0
  • 1
    @NoToJavaScript with the use of a proper language, NPE never happens. Never.
  • 1
    Division by something that isn't a size is actually extremely rare, and sizes are generally assumed to never be zero as part of the API contract.

    If my problem domain may include a zero in something I intend to use as a size, I usually handle it manually rather than checking whether the thing I'm sizing will be able to deal with it, because even if it does, its edge case handling almost certainly doesn't match my needs, and even if it does, it's cleaner to specify it explicitly, otherwise the next reader would have to dig up the same information I used.
  • 0
    Essentially the only place I ever met a division by zero error was in inverse square laws.
  • 0
    Yeah the few times it has happened to me it was due to bad data that would've messed something up anyway. Had a padding set to (image.width/image.height)%

    but turned out all images from old systems had 0 as both values. So the css would've failed anyway but now turned out as NaN%
Add Comment