From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13856 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: FE Exception triggered by comparison Date: Sun, 24 Feb 2019 20:25:11 +0100 Message-ID: <20190224192511.GZ21289@port70.net> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="191010"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: musl@lists.openwall.com Original-X-From: musl-return-13872-gllmg-musl=m.gmane.org@lists.openwall.com Sun Feb 24 20:25:27 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1gxzOw-000nZ1-1C for gllmg-musl@m.gmane.org; Sun, 24 Feb 2019 20:25:26 +0100 Original-Received: (qmail 20233 invoked by uid 550); 24 Feb 2019 19:25:23 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 20209 invoked from network); 24 Feb 2019 19:25:23 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:13856 Archived-At: * Damian McGuckin [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).