On to Hydro
Jonathan S. Shapiro
Fri, 18 Aug 2000 10:08:38 -0400
> > I don't want to divert the conversation too much, but could anyone
> > quickly tell me why division by 0 is even permitted (instead of
> > throwing an exception)? Are there algorithms in which it makes sense
> > to divide a number by zero? If so, why is division of an integer by
> > zero an exception?
The answers to this are complicated.
First off, see the discussion of floating point exception handling at
The basic answer to your question is that floating point computations often
have long chains of calculations, and it is often cheaper to let them run to
the end propagating the NaN than to take the exception. Exceptions are
*very* expensive things. On most processors you can elect to take the
exception or elect to have NaN reported.
The discussion at the above URL, along with the lecture notes on IEEE
floating point that is in turn cited in the first paragraph of the above,
should answer most of your questions. If they don't, I probably don't know
enough about it either.