Assaf Gordon:

> On OpenBSD-5.7/amd64 (under qemu/kvm), I'm getting incorrect results
> when using ceill(3). For values between 0 and 1, the returned value
> is 0, while I'd expected it to be 1. Using ceil(3) does return 1 as
> expected. Is this my incorrect usage or a bug?

It's a bug in the ceill(3) implementation for x86 extended precision
numbers.  Contrary to the IEEE single/double formats, the fraction
part has no implicit bit.

Index: src/ld80/s_ceill.c
===================================================================
RCS file: /cvs/src/lib/libm/src/ld80/s_ceill.c,v
retrieving revision 1.2
diff -u -p -r1.2 s_ceill.c
--- src/ld80/s_ceill.c  25 Jul 2011 16:20:09 -0000      1.2
+++ src/ld80/s_ceill.c  6 Aug 2015 21:44:02 -0000
@@ -37,7 +37,7 @@ ceill(long double x)
            if(jj0<0) { /* raise inexact if x != 0 */
                if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
                    if(sx) {se=0x8000;i0=0;i1=0;}
-                   else if((i0|i1)!=0) { se=0x3fff;i0=0;i1=0;}
+                   else if((i0|i1)!=0) { se=0x3fff;i0=0x80000000;i1=0;}
                }
            } else {
                i = (0x7fffffff)>>jj0;
-- 
Christian "naddy" Weisgerber                          [email protected]

Reply via email to