summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2014-02-11 18:21:51 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2014-02-11 18:21:51 +0000
commitb93bb0e95e9d9d64b517e7a6cbce701634b1fa07 (patch)
treeaba2b6101ef7f1a1456f94005adc92ab1a5205a9 /lib
parent55beae733f22433610b5b34b959232ff1572c416 (diff)
Make floor round to integral value less than x, when x is tiny.
Reported by dcoppa@, thanks! OK kettenis@, dcoppa@.
Diffstat (limited to 'lib')
-rw-r--r--lib/libm/src/ld128/s_floorl.c7
-rw-r--r--lib/libm/src/ld80/s_floorl.c7
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/libm/src/ld128/s_floorl.c b/lib/libm/src/ld128/s_floorl.c
index e3c05d1c914..a7d8140cc64 100644
--- a/lib/libm/src/ld128/s_floorl.c
+++ b/lib/libm/src/ld128/s_floorl.c
@@ -34,10 +34,11 @@ floorl(long double x)
jj0 = ((i0>>48)&0x7fff)-0x3fff;
if(jj0<48) {
if(jj0<0) { /* raise inexact if x != 0 */
- if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
- if(i0>=0) {i0=i1=0;}
+ if(huge+x>0.0) {
+ if(i0>=0)
+ return 0.0L;
else if(((i0&0x7fffffffffffffffLL)|i1)!=0)
- { i0=0xbfff000000000000ULL;i1=0;}
+ return -1.0L;
}
} else {
i = (0x0000ffffffffffffULL)>>jj0;
diff --git a/lib/libm/src/ld80/s_floorl.c b/lib/libm/src/ld80/s_floorl.c
index a1751ab9615..a5b787796bc 100644
--- a/lib/libm/src/ld80/s_floorl.c
+++ b/lib/libm/src/ld80/s_floorl.c
@@ -35,10 +35,11 @@ floorl(long double x)
jj0 = (se&0x7fff)-0x3fff;
if(jj0<31) {
if(jj0<0) { /* raise inexact if x != 0 */
- if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
- if(sx==0) {se=0;i0=i1=0;}
+ if(huge+x>0.0) {
+ if(sx==0)
+ return 0.0L;
else if(((se&0x7fff)|i0|i1)!=0)
- { se=0xbfff;i0=i1=0;}
+ return -1.0L;
}
} else {
i = (0x7fffffff)>>jj0;