*BSD News Article 96718


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!howland.erols.net!vixen.cso.uiuc.edu!uwm.edu!miller.cs.uwm.edu!bacon
From: bacon@cs.uwm.edu (Jason Bacon)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: FreeBSD 221 math problem, help
Date: 2 Jun 1997 15:09:04 GMT
Organization: University of Wisconsin - Milwaukee
Lines: 23
Message-ID: <5munmg$kl9@uwm.edu>
References: <01bc6afa$0dd23720$3976c9ce@amuancw110>
NNTP-Posting-Host: 129.89.139.22
X-Newsreader: TIN [version 1.2 PL2]
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:42044

Tim Brown (Tim.Brown@ctg.com) wrote:
: I am getting a math error (FPE) in some pretty old code.  The code works
: basically everywhere but freebsd 221.  It even seems to work on older
: freebsd systems.

: The code is:

: -216 + 5 -1316 *40 / (40 * -.00012120)

: I have broken it down like so to narrow it down:

: double x = -217 +5 -1316 *40;
: double y= 40 * -.00012120;
: double a = x/y;

: I ran this and when I got the FPE while in gdb, y was 0.  Why??
: It seems that "y" was rounded off to 0.  All other OS's I have run this on
: (AIX, SunOS, older freeBSD, others) do not have this problem.  Is there a
: magical gcc command line option I need to use?

Are you compiling with optimizations?  If so, try shutting them off.

-Jason