[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: trapping SIGFPE
From: |
Andreas Jaeger |
Subject: |
Re: trapping SIGFPE |
Date: |
Fri, 15 Mar 2002 15:35:15 +0100 |
User-agent: |
Gnus/5.090006 (Oort Gnus v0.06) XEmacs/21.4 (Artificial Intelligence, i386-suse-linux) |
Peter Jay Salzman <address@hidden> writes:
> dear all,
>
> i can't seem to trap any kind of floating point exception:
>
> #include <stdio.h>
> #include <signal.h>
> static void Exception(int signum);
>
> int main(void)
> {
> float bignum = 9E350;
> float smallnum = 9E-350;
>
> signal(SIGFPE, Exception);
>
> printf("%p\n", sigreturn);
> printf("%Lf\n", 2.0L / 0.0L);
> printf("%Le\n", bignum / smallnum);
> return 0;
> }
>
>
> void Exception(int signum)
> {
> printf("Caught SIGFPE: %d.\n", signum);
> exit(0);
> }
>
> SIGFPE isn't being caught, even though (i believe) i correctly installed
> a signal handler.
>
> what's going on here? how would i modify this program to catch an
> overflow, underflow or divide by zero?
Use the functions from <fenv.h> to enable trapping. By default we do
not trap for fp exceptions.
Andreas
--
Andreas Jaeger
SuSE Labs address@hidden
private address@hidden
http://www.suse.de/~aj
- trapping SIGFPE, Peter Jay Salzman, 2002/03/13
- Re: trapping SIGFPE,
Andreas Jaeger <=