From: Morten Welinder <mwelinder@gmail.com>
To: gcc@gcc.gnu.org, kth@srv.net
Subject: Re: Sine and Cosine Accuracy
Date: Thu, 26 May 2005 18:38:00 -0000 [thread overview]
Message-ID: <118833cc050526105626c8442a@mail.gmail.com> (raw)
> But, you are using a number in the range of 2^90, only
> have 64 bits for storing the floating point representation, and
> some of that is needed for the exponent.
> 2^90 would require 91 bits for the base alone (as an integer
> value), plus a couple more for the '*PI' portion, and then
> more for the exponent. And that wouldn't include anything
> past the decimal point.
> You are more than 30 bits short of getting a crappy result.
This is not right.
Floating point variables are perfectly capable of holding _some_ rather large
floating point numbers completely accurately. The integer 2^90 is one of them
(on a standard base-2 machine).
It is true that its nearest neighbours are about 2^30 away, but that is not
relevant for the accuracy of 2^90. pow(2.0,90.0) generates that value
with no error.
Therefore sin(2^90) is a well defined number somewhere between -1 and 1
and the C fragment
sin(pow(2.0,90.0))
should calculate it with at most one wrong bit at the end. (You get a one-bit
allowance since "sin" is trancendental.)
Morten
(who wouldn't be too surprised if some "sin" implementations failed to do that)
next reply other threads:[~2005-05-26 17:56 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-26 18:38 Morten Welinder [this message]
2005-05-26 20:58 ` Andrew Haley
-- strict thread matches above, loose matches on Subject: below --
2005-05-28 6:42 Menezes, Evandro
2005-05-28 4:32 Menezes, Evandro
2005-05-28 5:02 ` Scott Robert Ladd
2005-05-28 10:44 ` Gary Funck
2005-05-27 0:54 Menezes, Evandro
2005-05-27 0:54 ` Scott Robert Ladd
2005-05-27 12:42 ` Scott Robert Ladd
2005-05-27 0:39 Menezes, Evandro
2005-05-27 0:54 ` Scott Robert Ladd
2005-05-26 23:59 Menezes, Evandro
2005-05-27 15:19 ` Vincent Lefevre
2005-05-26 23:31 Uros Bizjak
2005-05-26 23:52 ` Paul Koning
2005-05-26 23:56 ` Gabriel Dos Reis
2005-05-26 23:57 ` Steven Bosscher
2005-05-27 15:09 ` Olivier Galibert
2005-05-27 15:28 ` Vincent Lefevre
2005-05-27 18:27 ` Marcin Dalecki
2005-05-26 17:53 Morten Welinder
2005-05-26 18:10 ` Scott Robert Ladd
2005-05-26 18:22 ` Dave Korn
2005-05-26 18:49 ` Scott Robert Ladd
2005-05-26 19:28 ` Dave Korn
2005-05-26 16:05 Scott Robert Ladd
2005-05-26 16:09 ` Andrew Haley
2005-05-26 16:33 ` Scott Robert Ladd
2005-05-26 17:14 ` Andrew Haley
2005-05-26 17:01 ` Paolo Carlini
2005-05-26 17:23 ` Richard Henderson
2005-05-26 17:24 ` Scott Robert Ladd
2005-05-26 17:27 ` Paul Koning
2005-05-26 17:27 ` Scott Robert Ladd
2005-05-26 17:29 ` Dave Korn
2005-05-26 17:37 ` David Daney
2005-05-26 17:56 ` Dave Korn
2005-05-26 17:40 ` Scott Robert Ladd
2005-05-26 18:12 ` Paul Koning
2005-05-26 18:32 ` Scott Robert Ladd
2005-05-26 18:50 ` Paul Koning
2005-05-26 19:14 ` Andrew Pinski
2005-05-26 19:35 ` Scott Robert Ladd
2005-05-29 6:22 ` Geoffrey Keating
2005-05-31 14:34 ` Paul Koning
2005-05-31 22:58 ` Geoff Keating
2005-05-29 12:07 ` Roger Sayle
2005-05-30 15:34 ` Vincent Lefevre
2005-05-29 2:22 ` Kai Henningsen
2005-05-29 18:16 ` Marc Espie
2005-05-29 20:58 ` Georg Bauhaus
2005-05-30 15:19 ` Gabriel Dos Reis
2005-05-30 15:19 ` Marc Espie
2005-05-30 17:26 ` Scott Robert Ladd
2005-05-30 17:18 ` Marc Espie
2005-05-30 18:11 ` Scott Robert Ladd
2005-05-30 17:31 ` Scott Robert Ladd
2005-05-31 3:10 ` chris jefferson
2005-05-31 12:17 ` Andrew Haley
2005-05-31 12:46 ` Scott Robert Ladd
2005-05-31 13:02 ` Andrew Haley
2005-05-31 13:34 ` Vincent Lefevre
2005-05-30 15:35 ` Bernhard R. Link
2005-05-30 18:59 ` Scott Robert Ladd
2005-05-30 19:16 ` Georg Bauhaus
2005-05-30 19:17 ` Bernhard R. Link
2005-05-30 19:54 ` Georg Bauhaus
2005-05-30 20:04 ` Gabriel Dos Reis
2005-05-26 17:35 ` Kevin Handy
2005-05-26 17:41 ` Paul Koning
2005-05-26 20:26 ` Joseph S. Myers
2005-05-26 21:15 ` Gabriel Dos Reis
2005-05-26 21:17 ` Scott Robert Ladd
2005-05-26 23:25 ` Gabriel Dos Reis
2005-05-27 0:18 ` Scott Robert Ladd
2005-05-27 0:54 ` Gabriel Dos Reis
2005-05-27 11:29 ` Marcin Dalecki
2005-05-27 9:36 ` Marcin Dalecki
2005-05-27 10:48 ` Marcin Dalecki
2005-05-26 21:33 ` Richard Henderson
2005-05-27 0:05 ` Scott Robert Ladd
2005-05-27 0:43 ` Gabriel Dos Reis
2005-05-27 0:54 ` Scott Robert Ladd
2005-05-28 11:26 ` Russ Allbery
2005-05-27 13:56 ` Vincent Lefevre
2005-05-29 3:36 ` Kai Henningsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=118833cc050526105626c8442a@mail.gmail.com \
--to=mwelinder@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=kth@srv.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).