Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!metro!metro!asstdc.scgt.oz.au!nsw.news.telstra.net!act.news.telstra.net!imci3!imci4!newsfeed.internetmci.com!panix!bloom-beacon.mit.edu!spool.mu.edu!usenet.eel.ufl.edu!tank.news.pipex.net!pipex!blackbush.xlink.net!zib-berlin.de!news.tu-chemnitz.de!irz401!uriah.heep!news From: j@uriah.heep.sax.de (J Wunsch) Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: Weird arithmetic Date: 29 Apr 1996 22:27:26 GMT Organization: Private FreeBSD site, Dresden Lines: 47 Message-ID: <4m3foe$3db@uriah.heep.sax.de> References: <4m0cqq$bv0@gap.cco.caltech.edu> Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) NNTP-Posting-Host: localhost.heep.sax.de Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: knews 0.9.6 stan@bombay.gps.caltech.edu ("Stan") writes: >There is a variable called ms: > >(gdb) print ms >$2 = 1.4101357041089591 > >This looks reasonable. Taking sin(ms) worked all right, but when we try >to take sin(2*ms), all hell breaks loose. I tried isolating the problem by >adding a line: > >x1 = 2*ms; >I suspect that there is something very fundamental that I'm missing here. >Anybody know what it is? Are you using <math.h>? 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; } j@uriah 98% cc foo.c -lm j@uriah 99% ./a.out ms = 1.410136, x1 = 2.820271 sin(ms) = 0.987122, sin(x1) = 0.315820 I can't find anything bogus in the above. -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)