Module Name: src
Committed By: drochner
Date: Wed Jan 27 14:07:41 UTC 2010
Modified Files:
src/lib/libm/src: s_modf.c s_modff.c
Log Message:
fix return value in case of NaN input
(the code also shortcuts the +-inf case, but this was OK before -- it
only avoids an extra check of the mantissa)
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libm/src/s_modf.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libm/src/s_modff.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libm/src/s_modf.c
diff -u src/lib/libm/src/s_modf.c:1.13 src/lib/libm/src/s_modf.c:1.14
--- src/lib/libm/src/s_modf.c:1.13 Sun Sep 28 18:54:55 2008
+++ src/lib/libm/src/s_modf.c Wed Jan 27 14:07:41 2010
@@ -12,7 +12,7 @@
#include <sys/cdefs.h>
#if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_modf.c,v 1.13 2008/09/28 18:54:55 christos Exp $");
+__RCSID("$NetBSD: s_modf.c,v 1.14 2010/01/27 14:07:41 drochner Exp $");
#endif
/*
@@ -57,6 +57,8 @@
} else if (jj0>51) { /* no fraction part */
u_int32_t high;
*iptr = x*one;
+ if (jj0 == 0x400) /* +-inf or NaN */
+ return 0.0 / x; /* +-0 or NaN */
GET_HIGH_WORD(high,x);
INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
return x;
Index: src/lib/libm/src/s_modff.c
diff -u src/lib/libm/src/s_modff.c:1.8 src/lib/libm/src/s_modff.c:1.9
--- src/lib/libm/src/s_modff.c:1.8 Fri Apr 25 22:21:53 2008
+++ src/lib/libm/src/s_modff.c Wed Jan 27 14:07:41 2010
@@ -15,7 +15,7 @@
#include <sys/cdefs.h>
#if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_modff.c,v 1.8 2008/04/25 22:21:53 christos Exp $");
+__RCSID("$NetBSD: s_modff.c,v 1.9 2010/01/27 14:07:41 drochner Exp $");
#endif
#include "math.h"
@@ -50,6 +50,8 @@
} else { /* no fraction part */
u_int32_t ix;
*iptr = x*one;
+ if (jj0 == 0x80) /* +-inf or NaN */
+ return 0.0 / x; /* +-0 or NaN */
GET_FLOAT_WORD(ix,x);
SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */
return x;