mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: FE Exception triggered by comparison
Date: Sun, 24 Feb 2019 20:25:11 +0100	[thread overview]
Message-ID: <20190224192511.GZ21289@port70.net> (raw)
In-Reply-To: <alpine.LRH.2.02.1902242244590.23511@key0.esi.com.au>

* Damian McGuckin <damianm@esi.com.au> [2019-02-25 00:28:20 +1100]:
> What comparison of FP numbers trigger invalid operation exceptions?
> 
> Does a comparison like
> 
> 	if (x != x)
> 	{
> 		/* get to here if x == NaN *
> 	}
> 
> which tests for a NaN cause an invalid operation if given an sNaN?

iso c does not say much about sNaN: a conforming implementation
does not have to support sNaN (it is usually treated as qNaN,
with unspecified signaling behaviour and you need special
compiler options to ensure sNaN breaking transformations are
not done if you want to rely on sNaN signals)

with c99 annex F, c == and != operators are mapped to ieee 754
compareQuiet{Not}Equal, which is non-signaling with qNaN inputs
but signals invalid with sNaN inputs, so in practice sNaN != sNaN
will signal in c.

> Even reading the standard numerous times and I am not any wiser.

i think it's better to look at the ieee 754 spec instead
of the c spec, drafts are at http://754r.ucbtest.org/drafts/

annex F.3 describes how c is mapped to ieee 754 (iec 60559
is supposed to be very close to ieee 754).

ts 18661-* provides more detailed description of the mapping
to ieee 754-2008 (it will likely be part of c2x and it is a
bit more strict than what iso c currently allows).


  parent reply	other threads:[~2019-02-24 19:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-24 13:28 Damian McGuckin
2019-02-24 17:12 ` Markus Wichmann
2019-02-24 19:25 ` Szabolcs Nagy [this message]
2019-02-24 20:04   ` Jens Gustedt
2019-02-24 21:50     ` Damian McGuckin
2019-02-25  5:21       ` Damian McGuckin
2019-02-25 15:51       ` Markus Wichmann
2019-02-26  3:55         ` Damian McGuckin
2019-02-27 14:14           ` Alexander Monakov
2019-02-27 15:38             ` Damian McGuckin
2019-02-27 16:00               ` Alexander Monakov
2019-02-27 16:09                 ` Damian McGuckin
2019-02-27 16:14                   ` Markus Wichmann
2019-02-27 16:20                     ` Damian McGuckin
2019-02-28  1:07                     ` Damian McGuckin
2019-02-28  1:27                       ` Rich Felker
2019-02-28  2:28                         ` Damian McGuckin
2019-02-27 16:32                   ` Alexander Monakov
2019-02-27 16:42                     ` Rich Felker
2019-02-27 17:08                       ` Szabolcs Nagy
2019-02-27 17:14                       ` Alexander Monakov
2019-02-27 17:26                         ` Rich Felker
2019-02-27 19:36                           ` Szabolcs Nagy
2019-02-27 19:48                           ` Alexander Monakov
2019-02-27 20:16                             ` Szabolcs Nagy
2019-02-27 20:35                               ` Rich Felker
2019-02-27 21:03                                 ` Szabolcs Nagy

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=20190224192511.GZ21289@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).