Assaf Gordon <assafgordon <at> gmail.com> writes:

> 
> Hello,
> 
> 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?
> any advice/comment will be appreciated.
> 

It's a bug in the libm library. The 80-bit extended precision format has an
explicit leading bit for the integer part of a significand. Thus the line

    else if((i0|i1)!=0) { se=0x3fff;i0=0;i1=0;}

in /src/lib/libm/src/ld80/s_ceill.c should read

    else if((i0|i1)!=0) { se=0x3fff;i0=0x80000000;i1=0;}

or simpler still

    else if((i0|i1)!=0) { return 1.0L; }

Best regards,
Nick Permyakov

Reply via email to