From: Joseph Myers <joseph@codesourcery.com>
To: Ruinland ChuanTzu Tsai <ruinland@andestech.com>
Cc: <libc-alpha@sourceware.org>
Subject: Re: In libm, sin(qNaN) doesn't expect FE_INVALID ?
Date: Tue, 8 Sep 2020 15:06:34 +0000 [thread overview]
Message-ID: <alpine.DEB.2.21.2009081459380.8874@digraph.polyomino.org.uk> (raw)
In-Reply-To: <20200908110214.GA3365@APC301.andestech.com>
On Tue, 8 Sep 2020, Ruinland ChuanTzu Tsai wrote:
> If I may, I have another question upon sin,atan(±0x4p-1076), the test-
> suite expects FE_UNDERFLOW being raised.
>
> In `math/libm-test-{sin,atan}.inc` , I cannot see the corresponding
> expectation being set.
That's because tests with finite inputs and finite mathematical results
(possibly overflowing the floating-point type) generally go in
auto-libm-test-in to have the expected results generated automatically by
gen-auto-libm-tests; libm-test-*.inc are mainly for cases where the inputs
or results involve exact infinities or NaNs.
> if (k < 0x3e500000) /* if x->0 =>sin(x)=x */
> {
> math_check_force_underflow (x);
> retval = x;
> }
> ```
>
> I've read IEEE Standard Section 7.5 which regulates that if a tiny non-
> zero number is detected, an exception shall be raised. However I'm not
> so sure about the reason why the magic number is set to `0x3e500000`.
That is a check for whether the argument is small enough that the argument
itself is an accurate return value (then math_check_force_underflow does
the separate check for whether it's small enough that the underflow
exception must be raised). As sin(x) = x - x^3/6 + ..., if x^2/6 is
around 2^-54 or smaller, the error from returning x as the result is
small. That reasoning leads to the comparison of the leading bits of the
representation against 0x3e500000 (i.e. comparing |x| against 0x1p-26).
--
Joseph S. Myers
joseph@codesourcery.com
next prev parent reply other threads:[~2020-09-08 15:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-03 12:34 Ruinland ChuanTzu Tsai
2020-09-03 13:19 ` Adhemerval Zanella
2020-09-03 17:03 ` Joseph Myers
2020-09-08 11:02 ` Ruinland ChuanTzu Tsai
2020-09-08 15:06 ` Joseph Myers [this message]
2020-09-10 13:49 ` Ruinland ChuanTzu Tsai
2020-09-10 15:26 ` Joseph Myers
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=alpine.DEB.2.21.2009081459380.8874@digraph.polyomino.org.uk \
--to=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=ruinland@andestech.com \
/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).