This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/19848] New: powl(10,n) for n=-4,-5,-6,-7 is off by more than 1 ULP


https://sourceware.org/bugzilla/show_bug.cgi?id=19848

            Bug ID: 19848
           Summary: powl(10,n) for n=-4,-5,-6,-7 is off by more than 1 ULP
           Product: glibc
           Version: 2.23
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: b7.10110111 at gmail dot com
  Target Milestone: ---

Here's a sample program, which demonstrates the problem:

#include <stdio.h>
#include <math.h>

long double before(long double x)
{ return nextafterl(x,-INFINITY); }

void test(int exponent,long double reference)
{
    const long double tenToPow=powl(10.L,exponent);
    const long double bef1=before(tenToPow);
    const long double bef2=before(bef1);
    const long double bef3=before(bef2);
    printf("exponent: %d\n",exponent);
    printf("before^3  %.21Lg%s\n",bef3,reference==bef3?"<-best":"");
    printf("before^2  %.21Lg%s\n",bef2,reference==bef2?"<-best":"");
    printf("before^1  %.21Lg%s\n",bef1,reference==bef1?"<-best":"");
    printf("at       [%.21Lg]\n",tenToPow);
}

int main()
{
    test(-7,1e-7L);
    test(-6,1e-6L);
    test(-5,1e-5L);
    test(-4,1e-4L);
}


Its output:

exponent: -7
before^3  9.99999999999999999985e-08<-best
before^2  1.00000000000000000005e-07
before^1  1.00000000000000000011e-07
at       [1.00000000000000000018e-07]
exponent: -6
before^3  9.99999999999999999933e-07
before^2  1.00000000000000000004e-06<-best
before^1  1.00000000000000000014e-06
at       [1.00000000000000000024e-06]
exponent: -5
before^3  9.99999999999999999912e-06
before^2  9.99999999999999999995e-06<-best
before^1  1.00000000000000000008e-05
at       [1.00000000000000000016e-05]
exponent: -4
before^3  9.99999999999999999945e-05
before^2  0.000100000000000000000001<-best
before^1  0.000100000000000000000008
at       [0.000100000000000000000014]


Tested on Ubuntu 15.10 with glibc versions 2.21 and 2.23, uname -a gives
Linux integral3-amd64 4.2.0-22-generic #27-Ubuntu SMP Thu Dec 17 22:57:08 UTC
2015 x86_64 x86_64 x86_64 GNU/Linux.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]