Article View: comp.os.msdos.programmer
Article #1773Re: Turbo C matherr() function
From: Pete Holzmann
Date: Fri, 03 Aug 1990 13:13
Date: Fri, 03 Aug 1990 13:13
28 lines
1746 bytes
1746 bytes
broehl@watserv1.waterloo.edu (Bernie Roehl) writes:
>The problem is simple... maybe the solution will be, too.
>I'm trying to define my own matherr() function, as described on page 242 of
>the Reference Guide.
>
>I then write a short program that just divides by zero, link it with the above,
>and run it. Instead of "Hello, world!\n", I get the standard Turboc C
>"Floating point error: Divide by 0".
>
>Any ideas/suggestions/etc will be much appreciated. Thanks in advance...
Unfortunately, the solution is not as simple as you would like.
matherr() only deals with the errors that it is documented to deal
with. Basically, it is only called when an error is generated within
the trig/exponential functions.
To handle divide by zero and a host of other problems, you must set
up a signal handler for SIG_FPE (see signal()). This also requires
careful use of setjmp() and longjmp(). Which can be truly a pain in
the neck!
Pete
--
Peter Holzmann, Octopus Enterprises |(if you're a techie Christian & are
19611 La Mar Ct., Cupertino, CA 95014 |interested in helping w/ the Great
UUCP: {hpda,pyramid}!octopus!pete |Commission, email dsa-contact@octopus)
DSA office ans mach=408/996-7746;Work (SLP) voice=408/985-7400,FAX=408/985-0859
Technical Details
Message-ID:
<1990Aug3.131340.16334@Octopus.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!decwrl!apple!vsi1!octopus!peteReferences:
<1990Aug1.125327.26101@watserv1.waterloo.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!decwrl!apple!vsi1!octopus!pete From: pete@Octopus.COM (Pete Holzmann) Newsgroups: comp.os.msdos.programmer Subject: Re: Turbo C matherr() function Summary: Deal with SIG_FPE too! Message-ID: <1990Aug3.131340.16334@Octopus.COM> Date: 3 Aug 90 13:13:40 GMT References: <1990Aug1.125327.26101@watserv1.waterloo.edu> Reply-To: pete@octopus.COM (Pete Holzmann) Distribution: comp Organization: Octopus Enterprises, Cupertino CA Lines: 28