🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #1774

Re: Turbo C matherr() function

#1774
From: RAMontante
Date: Fri, 03 Aug 1990 15:26
15 lines
1205 bytes
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...
Technical Details
Message-ID: <53133@iuvax.cs.indiana.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!ux1.cso.uiuc.edu!iuvax!bobmon

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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