Thread View: comp.sys.acorn.tech
2 messages
2 total messages
Started by Paul Moore
Wed, 06 Jan 1993 21:16
Suppressing floating point errors in C
Author: Paul Moore
Date: Wed, 06 Jan 1993 21:16
Date: Wed, 06 Jan 1993 21:16
35 lines
1161 bytes
1161 bytes
The following code, when compiled, generates a stack backtrace,
and the program exits with status zero. How do I get the program
to continue to the "return 0"? (Note: I KNOW ignoring FP errors
is not good in the general case - in this case, and in the "real"
case where this is a problem for me, the naff value in d is never
used, and so is harmless.)
-------- Cut here --------
#include <signal.h>
/* Dummy - see below */
void a (double d)
{
}
int main (void)
{
double d;
signal (SIGFPE, SIG_IGN);
d = 1.0;
d /= 0.0;
/* To ensure that the compiler does not
* optimise away the floating point operation
*/
a (d);
return 0;
}
-------- Cut Here --------
Thanks in advance for any help.
Gustav.
Re: Suppressing floating point errors in C
Author: mckay_g
Date: Fri, 08 Jan 1993 11:32
Date: Fri, 08 Jan 1993 11:32
19 lines
1402 bytes
1402 bytes
In article <memo.845760@cix.compulink.co.uk>, pmoore@cix.compulink.co.uk (Paul Moore) writes: > The following code, when compiled, generates a stack backtrace, > and the program exits with status zero. How do I get the program > to continue to the "return 0"? (Note: I KNOW ignoring FP errors > is not good in the general case - in this case, and in the "real" > case where this is a problem for me, the naff value in d is never > used, and so is harmless.) [ Program deleted to overcome a stupid limitation of this silly news reader where you have to write more lines than you quote!] The way I would overcome this problem is to change the FPU status/control register to prevent what ever type of FP errors you wish to ignore. The only problem with this is that you would have to remember these registers and restore them when you exit your program or if it is running under the wimp, every time you call wimp_poll. Rob.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads