*BSD News Article 43244


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!yarrina.connect.com.au!warrane.connect.com.au!godzilla.zeta.org.au!not-for-mail
From: bde@zeta.org.au (Bruce Evans)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: freebsd 2.0 math library broken?
Date: 8 Mar 1995 12:20:56 +1000
Organization: Kralizec Dialup Unix Sydney - +61-2-837-1183, v.32bis v.42bis
Lines: 39
Message-ID: <3jj4a8$vfd@godzilla.zeta.org.au>
References: <D51yt4.Dxp@chaco.cs.unm.edu>
NNTP-Posting-Host: localhost.zeta.org.au

In article <D51yt4.Dxp@chaco.cs.unm.edu>,
Brent McClure <mcclure@chaco.cs.unm.edu> wrote:
>I'm getting rampant floating exceptions while running some pretty 
>routine calls to the math library which should generate an error,
>but not core dump.  The following two programs generate a FPE and
>core on my system:
>
>#include<stdio.h>
>#include<math.h>
>main()
>{
>  double d;
>  d = pow(3.0,1000001.0);
>  d = pow(4.0,1000001.0);
>}
>
>or
>...
>  acos(-2.0);

Use

#include <floatingpoint.h>
main()
{
  fpsetmask(0);
  ...
}

Your program needs to be careful about error handling if you do this.
libm is configured to only support IEEE754 error reporting, not ANSI
error reporting.  The core dumps are because  the default FPU exception
mask causes overflow errors to trap.

>What do I need to upgrade to fix this?

It isn't properly fixed in FreeBSD yet.
-- 
Bruce Evans  bde@zeta.org.au