floating point overflows (and how to catch them), HELP!
Scott Pace
scott at othervax.UUCP
Thu Aug 29 23:59:33 AEST 1985
If I compile and run the following program, it will continue until
a floating point overflow occurs and will then go and proccess
the interrupt routine. However, it seems that the return from the
interrupt routine is returning to the start of the instruction
which caused the overflow in the first place. Therefore, the program
just goes into an infinite loop printing the overflow message.
What exactly is happening here or what am I doing wrong ? Any help
greatly appreciated.
By the way, this is on a VAX11/780 running 4.1BSD
#include <signal.h>
int fpe_flag = 0;
main()
{
double a = 1.0,b = 2.0;
int fltover();
sigset(SIGFPE,fltover);
for (;;) {
a *= b; /* overflow here */
if (fpe_flag)
exit(1);
}
}
fltover()
{
printf("Floating point overflow\n");
fpe_flag = 1;
}
Cheers,
Scott Pace, ...!philabs!micomvax!othervax!scott
More information about the Comp.unix.wizards
mailing list