public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix truncf for sNaN input
@ 2020-03-11  9:58 Fabian Schriever
  2020-03-11 11:13 ` Corinna Vinschen
  2020-03-11 20:48 ` Keith Packard
  0 siblings, 2 replies; 13+ messages in thread
From: Fabian Schriever @ 2020-03-11  9:58 UTC (permalink / raw)
  To: newlib; +Cc: Fabian Schriever

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.
---
 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;
 
-- 
2.24.1.windows.2



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-03-17 22:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11  9:58 [PATCH] Fix truncf for sNaN input Fabian Schriever
2020-03-11 11:13 ` Corinna Vinschen
2020-03-11 20:48 ` Keith Packard
2020-03-11 21:47   ` Joseph Myers
2020-03-11 22:41     ` Keith Packard
2020-03-11 23:14       ` Joseph Myers
2020-03-16 19:50         ` Keith Packard
2020-03-17  1:30           ` Joseph Myers
2020-03-17  4:04             ` Keith Packard
2020-03-17 22:24               ` Joseph Myers
2020-03-17 15:26             ` Fabian Schriever
2020-03-17 19:34               ` Brian Inglis
2020-03-17 22:29               ` Joseph Myers

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).