[PATCH] Fix truncf for sNaN input

Keith Packard keithp@keithp.com
Wed Mar 11 20:48:26 GMT 2020


Fabian Schriever <fabian.schriever@gtd-gmbh.de> writes:

> Make line 47 in sf_trunc.c reachable. While converting the double
> precision function trunc to the single precision version truncf an error
> was introduced into the special case. This special case is meant to
> catch both NaNs and infinities, however qNaNs and infinities work just
> fine with the simple return of x (line 51). The only error occurs for
> sNaNs where the same sNaN is returned and no invalid exception is
> raised.

I think this isn't right. According to the trunc/truncf man page:

       If x is integral, infinite, or NaN, x itself is returned.

I think this means that we should just return x in these cases, and not
raise an exception?

The same appears to be true for the other similar functions, including
floor, ceil, round, rint and nearbyint.

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20200311/1b79df51/attachment.sig>


More information about the Newlib mailing list