*BSD News Article 97082


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.Hawaii.Edu!news.caldera.com!enews.sgi.com!nntprelay.mathworks.com!news.mathworks.com!news-xfer.cybernet.dk!news.onramp.net!news-in.iadfw.net!news.gymnet.com!LSNT1!lsbsdi6.lightspeed.net!news-ana-7.sprintlink.net!news-ana-24.sprintlink.net!news-west.sprintlink.net!news-peer.sprintlink.net!news.sprintlink.net!Sprint!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: 24
Message-ID: <62BD393EC5C730D4.C8DFB491DB8A6D36.CBD2F013DF4A0B08@library-proxy.airnews.net>
X-Orig-Message-ID: <5munmg$kl9@uwm.edu>
References: <01bc6afa$0dd23720$3976c9ce@amuancw110>
NNTP-Proxy-Relay: library.airnews.net
NNTP-Posting-Host: biceps.gymnet.com
X-Newsreader: TIN [version 1.2 PL2]
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:42377

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