diff options
author | Martynas Venckus <martynas@cvs.openbsd.org> | 2011-04-17 13:59:55 +0000 |
---|---|---|
committer | Martynas Venckus <martynas@cvs.openbsd.org> | 2011-04-17 13:59:55 +0000 |
commit | 618b21ca0a27729ae0bf4226c533540e758a3ab4 (patch) | |
tree | c1614ce9c02c3268d772621e50abbaa9c7906261 /lib | |
parent | 66e06ec8570a0086ca9fdce67a3b30be7c9deb8e (diff) |
The {,l}lround{,f} implementations are based on {,l}lrint{,f},
therefore affected by the same bugs I've fixed a week ago.
The high part was being clipped for all exponents greater or equal
to 52. Fix this to use RESTYPE_BITS instead; also make the code
consistent.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libm/src/s_lrint.c | 6 | ||||
-rw-r--r-- | lib/libm/src/s_lrintf.c | 4 | ||||
-rw-r--r-- | lib/libm/src/s_lround.c | 10 | ||||
-rw-r--r-- | lib/libm/src/s_lroundf.c | 6 |
4 files changed, 13 insertions, 13 deletions
diff --git a/lib/libm/src/s_lrint.c b/lib/libm/src/s_lrint.c index fd9bc1e7a0a..47726b4b3b8 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.4 2011/04/10 20:42:09 martynas Exp $ */ +/* $OpenBSD: s_lrint.c,v 1.5 2011/04/17 13:59:54 martynas Exp $ */ /* $NetBSD: lrint.c,v 1.3 2004/10/13 15:18:32 drochner Exp $ */ /*- @@ -84,12 +84,12 @@ LRINTNAME(double x) if (shift >=0) res = (shift < RESTYPE_BITS ? (RESTYPE)i1 << shift : 0); else - res = (shift > -RESTYPE_BITS ? i1 >> -shift : 0); + res = (shift > -RESTYPE_BITS ? (RESTYPE)i1 >> -shift : 0); shift += 32; if (shift >=0) res |= (shift < RESTYPE_BITS ? (RESTYPE)i0 << shift : 0); else - res |= (shift > -RESTYPE_BITS ? i0 >> -shift : 0); + res |= (shift > -RESTYPE_BITS ? (RESTYPE)i0 >> -shift : 0); return (s ? -res : res); } diff --git a/lib/libm/src/s_lrintf.c b/lib/libm/src/s_lrintf.c index 5844909a4c6..c94072bd74b 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.3 2011/04/10 20:42:09 martynas Exp $ */ +/* $OpenBSD: s_lrintf.c,v 1.4 2011/04/17 13:59:54 martynas Exp $ */ /* $NetBSD: lrintf.c,v 1.3 2004/10/13 15:18:32 drochner Exp $ */ /*- @@ -86,7 +86,7 @@ LRINTNAME(float x) if (shift >=0) res = (shift < RESTYPE_BITS ? (RESTYPE)i0 << shift : 0); else - res = (shift > -RESTYPE_BITS ? i0 >> -shift : 0); + res = (shift > -RESTYPE_BITS ? (RESTYPE)i0 >> -shift : 0); return (s ? -res : res); } diff --git a/lib/libm/src/s_lround.c b/lib/libm/src/s_lround.c index 9f983ca0005..647e35396d7 100644 --- a/lib/libm/src/s_lround.c +++ b/lib/libm/src/s_lround.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_lround.c,v 1.2 2011/04/17 10:37:07 martynas Exp $ */ +/* $OpenBSD: s_lround.c,v 1.3 2011/04/17 13:59:54 martynas Exp $ */ /* $NetBSD: lround.c,v 1.2 2004/10/13 15:18:32 drochner Exp $ */ /*- @@ -75,14 +75,14 @@ LROUNDNAME(double x) shift = e - DBL_FRACBITS; if (shift >=0) - res = (shift < 32 ? (RESTYPE)i1 << shift : 0); + res = (shift < RESTYPE_BITS ? (RESTYPE)i1 << shift : 0); else - res = (shift > -32 ? i1 >> -shift : 0); + res = (shift > -RESTYPE_BITS ? (RESTYPE)i1 >> -shift : 0); shift += 32; if (shift >=0) - res |= (shift < 32 ? (RESTYPE)i0 << shift : 0); + res |= (shift < RESTYPE_BITS ? (RESTYPE)i0 << shift : 0); else - res |= (shift > -32 ? i0 >> -shift : 0); + res |= (shift > -RESTYPE_BITS ? (RESTYPE)i0 >> -shift : 0); return (s ? -res : res); } diff --git a/lib/libm/src/s_lroundf.c b/lib/libm/src/s_lroundf.c index aee5ca0cd9b..7858008cab9 100644 --- a/lib/libm/src/s_lroundf.c +++ b/lib/libm/src/s_lroundf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_lroundf.c,v 1.1 2008/07/21 20:29:14 martynas Exp $ */ +/* $OpenBSD: s_lroundf.c,v 1.2 2011/04/17 13:59:54 martynas Exp $ */ /* $NetBSD: lroundf.c,v 1.2 2004/10/13 15:18:32 drochner Exp $ */ /*- @@ -75,9 +75,9 @@ LROUNDNAME(float x) shift = e - SNG_FRACBITS; if (shift >=0) - res = (shift < 32 ? (RESTYPE)i0 << shift : 0); + res = (shift < RESTYPE_BITS ? (RESTYPE)i0 << shift : 0); else - res = (shift > -32 ? i0 >> -shift : 0); + res = (shift > -RESTYPE_BITS ? (RESTYPE)i0 >> -shift : 0); return (s ? -res : res); } |