Article View: borland.public.cppbuilder.nativeapi
Article #2166Re: log10: SING Error -> Try/Catch??
From: Thomas Maeder [TeamB]
Date: Wed, 18 Apr 2007 19:22
Date: Wed, 18 Apr 2007 19:22
39 lines
1950 bytes
1950 bytes
Dan <Dan@do.not.spam> writes:
> log10 functions where the value passed to the function is negative
> results in a "LOG10: DOMAIN error" if the value is 0 then it's a
> "LOG10: SING error" For example the following code will create a
> DOMAIN error.
>
>
> #include <math.h>
>
> double DoLogFunction(const double &val)
> {
> return log10(val);
> }
>
> void main()
The return type of main() has to be int.
> {
> DoLogFunction(0); //SING ERROR
> DoLogFunction(-1); //DOMAIN ERROR
> }
>
>
> Try/Catch around the 'DoLogFunction()' function call or even around
> the log10 call doesn't work.
Because what the program does is causing undefined behavior, not
throwing exceptions.
> What is the BEST way to do this type of trapping so that I don't get
> the error?
As for most problems, there isn't a uniform best solution.
Have you considered providing your own version of _matherr()?
Technical Details
Message-ID:
<m2r6qh32u2.fsf@glue.ch>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<462631f7@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5a0a347bf89aa6bf
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: log10: SING Error -> Try/Catch??
References: <462631f7@newsgroups.borland.com>
From: maeder@glue.ch (Thomas Maeder [TeamB])
Organization: TeamB
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobr p]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
Date: Wed, 18 Apr 2007 21:22:13 +0200
Message-ID: <m2r6qh32u2.fsf@glue.ch>
User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)
Cancel-Lock: sha1:UFfx43cOEE1sgyfmB7ldAd5onho=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
NNTP-Posting-Host: 84.73.227.225
X-Trace: newsgroups.borland.com 1176924190 84.73.227.225 (18 Apr 2007 12:23:10 -0800)
Lines: 39
X-Authenticated-User: tmaeder
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail