Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libm/src fix return value in case of NaN input
details: https://anonhg.NetBSD.org/src/rev/cb5e60e13c43
branches: trunk
changeset: 751186:cb5e60e13c43
user: drochner <drochner%NetBSD.org@localhost>
date: Wed Jan 27 14:07:41 2010 +0000
description:
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)
diffstat:
lib/libm/src/s_modf.c | 4 +++-
lib/libm/src/s_modff.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diffs (42 lines):
diff -r 791a5ee289c4 -r cb5e60e13c43 lib/libm/src/s_modf.c
--- a/lib/libm/src/s_modf.c Wed Jan 27 13:30:45 2010 +0000
+++ b/lib/libm/src/s_modf.c Wed Jan 27 14:07:41 2010 +0000
@@ -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;
diff -r 791a5ee289c4 -r cb5e60e13c43 lib/libm/src/s_modff.c
--- a/lib/libm/src/s_modff.c Wed Jan 27 13:30:45 2010 +0000
+++ b/lib/libm/src/s_modff.c Wed Jan 27 14:07:41 2010 +0000
@@ -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;
Home |
Main Index |
Thread Index |
Old Index