home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / acorn / tech / 1172 < prev    next >
Encoding:
Text File  |  1993-01-06  |  1.1 KB  |  46 lines

  1. Path: sparky!uunet!pipex!demon!cix.compulink.co.uk!pmoore
  2. Newsgroups: comp.sys.acorn.tech
  3. From: pmoore@cix.compulink.co.uk (Paul Moore)
  4. Subject: Suppressing floating point errors in C
  5. Reply-To: pmoore@cix.compulink.co.uk
  6. Date: Wed, 6 Jan 1993 21:16:00 +0000
  7. Message-ID: <memo.845760@cix.compulink.co.uk>
  8. Sender: usenet@demon.co.uk
  9. Lines: 35
  10.  
  11. The following code, when compiled, generates a stack backtrace,
  12. and the program exits with status zero. How do I get the program
  13. to continue to the "return 0"? (Note: I KNOW ignoring FP errors
  14. is not good in the general case - in this case, and in the "real"
  15. case where this is a problem for me, the naff value in d is never
  16. used, and so is harmless.)
  17.  
  18. -------- Cut here --------
  19. #include <signal.h>
  20.  
  21. /* Dummy - see below */
  22. void a (double d)
  23. {
  24. }
  25.  
  26. int main (void)
  27. {
  28.         double d;
  29.  
  30.         signal (SIGFPE, SIG_IGN);
  31.         d = 1.0;
  32.         d /= 0.0;
  33.  
  34.         /* To ensure that the compiler does not
  35.          * optimise away the floating point operation
  36.          */
  37.         a (d);
  38.  
  39.         return 0;
  40. }
  41. -------- Cut Here --------
  42.  
  43. Thanks in advance for any help.
  44.  
  45. Gustav.
  46.