unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Cc: libc-alpha@sourceware.org
Subject: Re: fix inaccuracy of j0f for x >= 2^127 when sin(x)+cos(x) is tiny
Date: Mon, 27 Jul 2020 21:35:29 +0000	[thread overview]
Message-ID: <alpine.DEB.2.21.2007272133330.13114@digraph.polyomino.org.uk> (raw)
In-Reply-To: <mwmu3knale.fsf@tomate.loria.fr>

On Mon, 27 Jul 2020, Paul Zimmermann wrote:

> +                   float x0 = 3.153646966e+38f;
> +                   float y = x - x0; /* exact */
> +                   /* sin(y) = sin(x)*cos(x0)-cos(x)*sin(x0) */
> +                   z = __sinf (y);
> +                   float eps = 8.17583368e-8f;
> +                   /* cos(x0) ~ -sin(x0) + eps */
> +                   z += eps * __cosf (x);
> +                   /* now z ~ (sin(x)-cos(x))*cos(x0) */
> +                   float cosx0 = -0.707106740f;

In new code we generally prefer to use hex float constants in such cases 
where a specific floating-point value is wanted.

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2020-07-27 21:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 17:15 fix inaccuracy of j0f for x >= 2^127 when sin(x)+cos(x) is tiny Paul Zimmermann
2020-07-27 21:35 ` Joseph Myers [this message]
2020-07-28  8:23   ` Paul Zimmermann
2020-07-28  9:19     ` Andreas Schwab
2020-07-28 10:50       ` Paul Zimmermann
2020-07-28 18:09         ` Adhemerval Zanella via Libc-alpha
2020-07-29  7:03           ` fix inaccuracy of j0f for x >= 2^127 when sin(x)+cos(x) is tiny (v2) Paul Zimmermann
2020-07-29 20:25             ` Adhemerval Zanella via Libc-alpha
2020-07-30  7:20               ` fix inaccuracy of j0f for x >= 2^127 when sin(x)+cos(x) is tiny (v3) Paul Zimmermann
2020-07-30  8:53                 ` Florian Weimer via Libc-alpha
2020-08-03 13:19                   ` fix inaccuracy of j0f for x >= 2^127 when sin(x)+cos(x) is tiny (v4) Paul Zimmermann

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

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.2007272133330.13114@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=Paul.Zimmermann@inria.fr \
    --cc=libc-alpha@sourceware.org \
    /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).