Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!metro!metro!asstdc.scgt.oz.au!nsw.news.telstra.net!act.news.telstra.net!vic.news.telstra.net!news.mira.net.au!inquo!in-news.erinet.com!imci5!imci4!newsfeed.internetmci.com!uwm.edu!fnnews.fnal.gov!nntp-server.caltech.edu!bombay.gps.caltech.edu!STAN From: stan@bombay.gps.caltech.edu ("Stan") Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: Weird arithmetic Date: 30 Apr 1996 16:14:07 GMT Organization: USGS Lines: 62 Message-ID: <4m5e8f$cjr@gap.cco.caltech.edu> References: <4m0cqq$bv0@gap.cco.caltech.edu> <4m3foe$3db@uriah.heep.sax.de> Reply-To: stan@bombay.gps.caltech.edu NNTP-Posting-Host: bombay.gps.caltech.edu In article <4m3foe$3db@uriah.heep.sax.de>, j@uriah.heep.sax.de (J Wunsch) writes: >stan@bombay.gps.caltech.edu ("Stan") writes: [tale of the sin function blowing up omitted] >>I suspect that there is something very fundamental that I'm missing here. > >Are you using <math.h>? Yes. >j@uriah 97% cat foo.c >#include <stdio.h> >#include <math.h> > >int >main(void) >{ > double ms, x1; > ms = 1.4101357041089591; > x1 = 2 * ms; > > printf("ms = %lf, x1 = %lf\nsin(ms) = %lf, sin(x1) = %lf\n", > ms, x1, sin(ms), sin(x1)); > > return 0; I tried this, too. I made a little test program, and the sin function worked fine. It still blows up in the ephem program, though. I can't figure out what is different there. Here is a bit of a gdb session: Breakpoint 2, m (t=0.90229211302906587, k=1116, mjd=0xefbfd844) at moonnf.c :56 56 x1 = sin(ms); (gdb) s 58 ddjd = (1.734e-1-3.93e-4*t)*x1; (gdb) print x1 $1 = 0.98712181873770088 (gdb) s 59 x2 = 2*ms; (gdb) s 60 x1 = sin(x2); (gdb) print x2 $2 = 2.8202714082179181 (gdb) s Program received signal SIGFPE, Arithmetic exception. 0x804c75e in __kernel_sin () (gdb) print ms $4 = 1.4101357041089591 Note that the first time, sin worked fine. The second time, it blew up. Note also that this same set of calculations works fine in the test program. -- ------------------------------------------------------------------------------- Stan Schwarz | "I just want to live like Yogi Bear stan@bombay.gps.caltech.edu | He kicks ass on the average bear." ---------------------------------------------------- -Stukas Over Bedrock -----