Path: utzoo!attcan!uunet!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!ux1.cso.uiuc.edu!iuvax!bobmon From: bobmon@iuvax.cs.indiana.edu (RAMontante) Newsgroups: comp.os.msdos.programmer Subject: Re: Turbo C matherr() function Message-ID: <53133@iuvax.cs.indiana.edu> Date: 3 Aug 90 15:26:38 GMT Distribution: comp Organization: malkaryotic Lines: 15 As Pete Holzmann says, matherr() only catches math errors in library functions. You must use the SIG_FPE/setjmp/longjmp facilities to handle "lower-level" math errors. I found that it was really hard to recover from a general math error --- what do you want to do on divide-by-zero, for example? Generate a largest-possible-value? print a message? ... The simplest thing to do is to simply clear everything out and longjmp back to some point in your code that precedes the failed operation (and your error-handler doesn't necessarily know where that is). Plug: I am told that my rpn calculator is queued for c.b.i.p. It includes source code, and I use both the matherr() and the SIG_FPE code to handle math errors. I don't claim it's the best example of such stuff, but it *is* a working example...