public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Ruinland ChuanTzu Tsai <ruinland@andestech.com>
Cc: <libc-alpha@sourceware.org>, <tesheng@andestech.com>
Subject: Re: In libm, sin(qNaN) doesn't expect FE_INVALID ?
Date: Thu, 3 Sep 2020 17:03:08 +0000	[thread overview]
Message-ID: <alpine.DEB.2.21.2009031654370.5940@digraph.polyomino.org.uk> (raw)
In-Reply-To: <20200903123442.GA5266@APC301.andestech.com>

On Thu, 3 Sep 2020, Ruinland ChuanTzu Tsai wrote:

> Hi all,
> sorry for the bothering.
> 
> Recently, as I'm testing some modification on libm, I happen to realize
> the fact that glibc's testsutie doesn't expect sin(+-qNaN) to trigger
> FE_INVALID, which is designed in `math/libm-test-sin.inc` :

See subclause 6.2 of IEEE 754: "Every general-computational and 
quiet-computational operation involving one or more input NaNs, none of 
them signaling, shall signal no exception, except fusedMultiplyAdd might 
signal the invalid operation exception (see 7.2).".

The special rule about fma(0, Inf, qNaN) (where the standard leaves 
unspecified whether the NaN operand takes precedence over the 
multiplication 0 * Inf that would raise "invalid" if not fused with an 
addition) is handled through INVALID_EXCEPTION_OK in libm-test-fma.inc.  
The cases of INVALID_EXCEPTION_OK for various complex functions are where 
Annex G in the C standard mentions an optional "invalid" exception, and 
those for the significand function are empirical, reflecting that that 
function is not part of any standard.  No function from any standard 
should be using INVALID_EXCEPTION_OK in the testsuite without explicit 
standard wording about such an exception being permitted but optional.

Note that conversions from floating-point formats to *integer* formats 
signal "invalid" for quiet NaN inputs, since the NaN can't be represented 
in the output format.  Likewise, some but not all comparison operations 
signal "invalid" for quiet NaN arguments (see subclause 5.8 of IEEE 754).

-- 
Joseph S. Myers
joseph@codesourcery.com

  parent reply	other threads:[~2020-09-03 17:03 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 [this message]
2020-09-08 11:02   ` Ruinland ChuanTzu Tsai
2020-09-08 15:06     ` Joseph Myers
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.2009031654370.5940@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=ruinland@andestech.com \
    --cc=tesheng@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).