Re: [PATCH] Fix truncf for sNaN input
Joseph Myers <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 16 Mar 2020, Keith Packard via Newlib wrote: > Joseph Myers <[email protected]> writes: > > > I don't think POSIX specifications should be trusted for how functions > > should behave with sNaN inputs. Rather, prefer the specifications from TS > > 18661-1 (or the latest C2x draft which has TS 18661-1 integrated). > > From my reading of that, I should only check for signaling vs quiet NaN, > ensuring that values are the right kind of NaN, but not any specific > value of NaN. > > I've adjusted the newlib tests like this: > > /* All signaling nans are the "same", as are all quiet nans */ > if (isnan(correct.value) && isnan(is) > && (issignaling(correct.value) == issignaling(is))) > { > /* PASS */ > } > > Does this seem correct? Yes. Only a few functions such as fabs and copysign are expected to preserve NaN payloads (and those functions also preserve whether the NaN is signaling and never raise exceptions). -- Joseph S. Myers [email protected]