public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Fix truncf for sNaN input
@ 2020-03-11 11:11 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2020-03-11 11:11 UTC (permalink / raw)
  To: newlib-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c56f53a2a04577f6e84ac96477fc8dc804d544ef

commit c56f53a2a04577f6e84ac96477fc8dc804d544ef
Author: Fabian Schriever <fabian.schriever@gtd-gmbh.de>
Date:   Wed Mar 11 10:58:05 2020 +0100

    Fix truncf for sNaN input
    
    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.

Diff:
---
 newlib/libm/common/sf_trunc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/newlib/libm/common/sf_trunc.c b/newlib/libm/common/sf_trunc.c
index 74ea933ce..8eb0554d8 100644
--- a/newlib/libm/common/sf_trunc.c
+++ b/newlib/libm/common/sf_trunc.c
@@ -42,7 +42,7 @@
     }
   else
     {
-      if (exponent_less_127 == 255)
+      if (exponent_less_127 == 128)
         /* x is NaN or infinite. */
         return x + x;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-11 11:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11 11:11 [newlib-cygwin] Fix truncf for sNaN input Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).