SIGFPE signal problem

Doug Gwyn gwyn at smoke.BRL.MIL
Tue Mar 20 09:30:05 AEST 1990


In article <5450 at rouge.usl.edu> pcb at gator.cacs.usl.edu (Peter C. Bahrs) writes:
>I am trying to detect overflow, 0 divide and, although it may seem
>unlikely, underflow.  Doesn't SIGFPE detect this?

SIGFPE is a signal that may (or may not, depending on the system) be
generated upon floating-point exception.  Most UNIX-based C
implementations will generate SIGFPE upon division by zero, some of
them upon other forms of overflow, but few of them upon underflow.
Some implementations generate no SIGFPE at all, e.g. Gould UTX-32,
whose hardware couples integer and floating exceptions and which
relies on benign integer overflow (so it must disable all arithmetic
exceptions, alas).

Some vendors provide ways for your program to control behavior upon
exception, e.g. #pragma, compiler option, or mode-setting library
function.

>a = 999999999999999999999999999999999999999999999999999999999999999999999999999999999.9;

This would be much more likely to generate a compile-time diagnostic
than a run-time overflow exception.



More information about the Comp.lang.c mailing list