summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2011-04-10 11:25:15 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2011-04-10 11:25:15 +0000
commit1abf7a5bafdea75dab59dba6247028e9627d2094 (patch)
treea871925c4a1659a4ea7a393e2904b789784bc3fb
parent083dfe08c00ebfd13c83b5fda188f99bf4d8e47d (diff)
The assumption that |1.0 * 2^exp| = 0, exp < -1 cannot be made when
we round towards -inf or +inf.
-rw-r--r--lib/libm/src/s_lrint.c8
-rw-r--r--lib/libm/src/s_lrintf.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/libm/src/s_lrint.c b/lib/libm/src/s_lrint.c
index 43684f3c503..65ba11f9d50 100644
--- a/lib/libm/src/s_lrint.c
+++ b/lib/libm/src/s_lrint.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: s_lrint.c,v 1.1 2006/09/25 20:25:41 kettenis Exp $ */
+/* $OpenBSD: s_lrint.c,v 1.2 2011/04/10 11:25:14 martynas Exp $ */
/* $NetBSD: lrint.c,v 1.3 2004/10/13 15:18:32 drochner Exp $ */
/*-
@@ -61,9 +61,6 @@ LRINTNAME(double x)
s = e >> DBL_EXPBITS;
e = (e & 0x7ff) - DBL_EXP_BIAS;
- /* 1.0 x 2^-1 is the smallest number which can be rounded to 1 */
- if (e < -1)
- return (0);
/* 1.0 x 2^31 (or 2^63) is already too large */
if (e >= (int)RESTYPE_BITS - 1)
return (s ? RESTYPE_MIN : RESTYPE_MAX); /* ??? unspecified */
@@ -80,6 +77,9 @@ LRINTNAME(double x)
i0 &= 0xfffff;
i0 |= (1 << 20);
+ if (e < 0)
+ return (0);
+
shift = e - DBL_FRACBITS;
if (shift >=0)
res = (shift < 32 ? (RESTYPE)i1 << shift : 0);
diff --git a/lib/libm/src/s_lrintf.c b/lib/libm/src/s_lrintf.c
index d045e116517..d86f2bb9eb4 100644
--- a/lib/libm/src/s_lrintf.c
+++ b/lib/libm/src/s_lrintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: s_lrintf.c,v 1.1 2006/09/25 20:25:41 kettenis Exp $ */
+/* $OpenBSD: s_lrintf.c,v 1.2 2011/04/10 11:25:14 martynas Exp $ */
/* $NetBSD: lrintf.c,v 1.3 2004/10/13 15:18:32 drochner Exp $ */
/*-
@@ -61,9 +61,6 @@ LRINTNAME(float x)
s = e >> SNG_EXPBITS;
e = (e & 0xff) - SNG_EXP_BIAS;
- /* 1.0 x 2^-1 is the smallest number which can be rounded to 1 */
- if (e < -1)
- return (0);
/* 1.0 x 2^31 (or 2^63) is already too large */
if (e >= (int)RESTYPE_BITS - 1)
return (s ? RESTYPE_MIN : RESTYPE_MAX); /* ??? unspecified */
@@ -82,6 +79,9 @@ LRINTNAME(float x)
i0 &= 0x7fffff;
i0 |= (1 << SNG_FRACBITS);
+ if (e < 0)
+ return (0);
+
shift = e - SNG_FRACBITS;
if (shift >=0)
res = (shift < 32 ? (RESTYPE)i0 << shift : 0);