Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 24 Feb 2019 20:25:11 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: FE Exception triggered by comparison

* Damian McGuckin <damianm@....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).

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.