We don't want to prevent programmers from using infinity or NaN in
floating point programs, so the only way to panic on floating point
division by zero is to insert an explicit zero check before each
floating point division. We could go that route if we want to, but I
don't think it's appropriate.
Integer division by zero should cause a panic.
Ian
Russ
Annex G in the C99 standard spells out a set of rules for complex
division. It covers everything explicitly except 0+0i / 0+0i; by
implication, and by the code example it gives for how to implement
complex division, the result of that is NaN+NaNi.
Here are the key points:
A complex or imaginary value with at least one infinite part is
regarded as an infinity (even if its other part is a NaN). A
complex or imaginary value is a finite number if each of its parts
is a finite number (neither infinite nor NaN). A complex or
imaginary value is a zero if each of its parts is a zero.
...
For most operand types, the value of the result of a binary
operator with an imaginary or complex operand is completely
determined, with reference to real arithmetic, by the usual
mathematical formula. For some operand types, the usual
mathematical formula is problematic because of its treatment of
infinities and because of undue overflow or underflow; in these
cases the result satisfies certain properties (specified in
G.5.1), but is not completely determined.
...
The / operator satisifies the following infinity properties for
all complex operands:
-- if the first operand is an infinity and the second operand is a
finite number, then the result of the / operator is an infinity;
-- if the first operand is a finite number and the second operand
is an infinity, then the result of the / operator is a zero;
-- if the first operand is a nonzero finite number or an infinity
and the second operand is a zero, then the result of the /
operator is an infinity.