Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Feb 1998 23:15:56 -0800 (PST)
From:      Tom Bartol <bartol@salk.edu>
To:        Jonathan Lemon <jlemon@americantv.com>
Cc:        freebsd-questions@FreeBSD.ORG, dmaddox@scsn.net, mika@sdna2.ucsd.edu
Subject:   Re: IEEE Floating Point question: Inf and NaN
Message-ID:  <Pine.BSF.3.96.980202230500.24947D-100000@dale.salk.edu>
In-Reply-To: <19980202224740.54577@right.PCS>

next in thread | previous in thread | raw e-mail | index | archive | help

Thanks to everyone for the very rapid response to this question.  We have
decided to try the fpsetmask call in the math code and see how things work
out.  We haven't yet tried the patch to npx.h suggested by Donald Maddox
but I'm wondering if any of you might be able give some more info on what
the pros and cons might be of the fpsetmask solution versus the npx.h
patch.  What exactly does __BETTER_BDE_NPXCW__ do compared to a
call to fpsetmask?  I looked through the mail archives and haven't come up
with any answers on my own.

Thanks again for your excellent help,

Tom


On Mon, 2 Feb 1998, Jonathan Lemon wrote:

> On Feb 02, 1998 at 04:33:30PM -0800, Tom Bartol wrote:
> > 
> > Hi,
> > 
> > I am asking this question on behalf of a friend who is helping to develop
> > a very nice mathematics tool.  I finally convinced him to try FreeBSD
> > (after much coaxing -- yeah!!), however in porting his code from Linux to
> > FreeBSD he has discovered that the math libraries in FreeBSD (2.2.5 and
> > -current) do not return "Inf" on 1.0/0.0 or "NaN" on 0.0/0.0 but rather
> > result in a rather unpleasant "Floating exception (core dumped)" !!!  Is
> > there some way to change this behavior so that it returns Inf or NaN as
> > appropriate.  I've compiled a little test program under native FreeBSD and
> > under /compat/linux and have found that the /compat/linux version returns
> > the appropriate Inf or NaN.
> > 
> > If the solution requires writing new code in the core math routines of
> > FreeBSD, how difficult would it be to tackle this job?  What documentation
> > would aid this quest?  It would be a shame to loose a good software
> > product from a commercial vendor due to something as silly as this. 
> > 
> 
>    man fpsetmask
> 
>   Something like fpsetmask(0), will probably fix the problem, although
> perhaps something a little less drastic like fpsetmask(~FP_X_DZ) might
> also be in order.
> 
> Here's a quote from the mailing list:
> 
> > Date:      Sat, 11 Oct 1997 17:01:47 +0930
> > From:      Mike Smith <mike@smith.net.au>                             
> > Sender:    owner-freebsd-hackers@FreeBSD.ORG                           
> > Subject:   Re: Floating point exceptions                      
> >     
> > IMHO FreeBSD does the correct thing; it notifies you of the exception.
> > It is your responsibility to decide what to do about it. 
> >        
> > I have spent not a little time carefully explaining to various
> > scientific programmers about arithmetic exceptions and why they should
> > care about them, and so far have had a 100% conversion rate.  If you
> > look a physicist in the eye and say "unquantifiable error", they will
> > usually listen.                                                      
> >        
> > mike                                                                
> 
> Probably Mike Smith or Bruce Evans can provide a detailed treatise
> (again) on exactly why the system behaves the way it does.
> --
> Jonathan
> 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980202230500.24947D-100000>