[PATCH] Fix truncf for sNaN input

Joseph Myers joseph@codesourcery.com
Tue Mar 17 22:24:07 GMT 2020


On Mon, 16 Mar 2020, Keith Packard via Newlib wrote:

> Joseph Myers <joseph@codesourcery.com> 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
joseph@codesourcery.com


More information about the Newlib mailing list