[net.bugs] division by zero

henry (05/18/82)

We recently switched from software-simulated floating point (in the
kernel rather than the user program, but that's a detail) to real live
hardware floating point.  The conversion uncovered some very interesting
things.  The fpsim package is not smart enough to spot division by zero,
which the hardware croaks on every time.  To quote somebody from Bell
(Mike Lesk?) out of context:  "it's amazing how many programs divide by
zero".  If you are contemplating a similar conversion, get your users
to clean up their programs *now*.

The single biggest problem we encountered was little thrown-together
data-analysis programs which used fopen() and fscanf() and never bothered
to check the return codes to see if these succeeded.  Global data is
of course initialized to zero, and newly-grown stack is all zeros, and
the result is a high probability of divide-by-zero when hastily-written
programs don't get exactly the input they expect.