Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!uwm.edu!ogicse!ucsd!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: SIGFPE signal problem Message-ID: <12383@smoke.BRL.MIL> Date: 19 Mar 90 23:30:05 GMT References: <5450@rouge.usl.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 21 In article <5450@rouge.usl.edu> pcb@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.