From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3485 invoked by alias); 31 May 2005 12:24:44 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 3432 invoked by uid 22791); 31 May 2005 12:24:36 -0000 Received: from smtpout17.mailhost.ntl.com (HELO mta09-winn.mailhost.ntl.com) (212.250.162.17) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 31 May 2005 12:24:36 +0000 Received: from aamta08-winn.mailhost.ntl.com ([212.250.162.8]) by mta09-winn.mailhost.ntl.com with ESMTP id <20050531122434.KHXV9046.mta09-winn.mailhost.ntl.com@aamta08-winn.mailhost.ntl.com> for ; Tue, 31 May 2005 13:24:34 +0100 Received: from zapata.pink ([82.16.12.40]) by aamta08-winn.mailhost.ntl.com with ESMTP id <20050531122434.CWHS2024.aamta08-winn.mailhost.ntl.com@zapata.pink> for ; Tue, 31 May 2005 13:24:34 +0100 Received: from zapata.pink (localhost.localdomain [127.0.0.1]) by zapata.pink (8.13.1/8.13.1) with ESMTP id j4VCOoRC001352; Tue, 31 May 2005 13:24:51 +0100 Received: (from aph@localhost) by zapata.pink (8.13.1/8.13.1/Submit) id j4VCOoPi001317; Tue, 31 May 2005 13:24:50 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17052.22417.153112.6859@zapata.pink> Date: Tue, 31 May 2005 13:02:00 -0000 From: Andrew Haley To: Scott Robert Ladd Cc: gcc@gcc.gnu.org Subject: Re: Sine and Cosine Accuracy In-Reply-To: <429C547A.8030906@coyotegulch.com> References: <4295DE66.2050701@coyotegulch.com> <20050526154754.GA10785@redhat.com> <4295F374.6070901@coyotegulch.com> <17045.62613.557950.285394@gargle.gargle.HOWL> <20050529155740.D440412D1A@quatramaran.ens.fr> <429A10F4.3040704@futureapps.de> <20050529192354.GA21142@lain.home> <429B369F.3040507@coyotegulch.com> <429B9E92.50507@cs.york.ac.uk> <429C547A.8030906@coyotegulch.com> X-SW-Source: 2005-05/txt/msg01679.txt.bz2 Scott Robert Ladd writes: > chris jefferson wrote: > > I would like to say yes, I disagree that this should be true. By your > > argument, why isn't sin(pow(2.0,90.0)+1) == sin(6.153104..)? Also, how > > the heck do you intend to actually calculate that value? You can't just > > keep subtracting multiples of 2*pi from pow(2.0, 90.0) else nothing will > > happen, and if you choose to subtract some large multiple of 2*pi, your > > answer wouldn't end up accurate to anywhere near that many decimal > > places. Floating point numbers approximate real numbers, and at the size > > you are considering, the approximation contains values for which sin(x) > > takes all values in the range [-1,1]. > > Nonsense. > > Show me an example where the following function should *not* print the > same values for a and b: > > void same_sines(double x) > { > double a = sin(x); > double b = sin(fmod(x, 2.0 * PI)); > printf("%20.15f,%20.15f\n",a,b); > } Please! Every correct implementation of libm will not print the same result for these two values, because it is necessary to do the range reduction in extended precision. Andrew.