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/1161] New: powf inaccurate for some inputs


The version of powf() in sysdeps/ieee754/flt-32/e_powf.c gives results that are wrong by more than 1 
ulp for at least some inputs.  The testcase below will demonstrate the problem for powf(-1.100000e
+00, 1.010000e+02).  The output from this test on an x86_64 platform running RH Enterprise 3 is:

inputs: a = -1.100000e+00 b = 1.010000e+02
actual    =     -1.5158703e+04  (0xc66cdad0)
expected  =     -1.5158707e+04  (0xc66cdad4)
pow(a, b) =     -1.5158706757936e+04

The actual value is off by 4 ulp from the expected value, so the absolute error must be at least 3 ulp.  
Other math libraries derived from fdlibm (e.g., newlib) have the same problem.  The test program is:

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

unsigned int ta = 0xBF8CCCCD;
unsigned int tb = 0x42CA0000;

main ()
{
  float a = *(float *)&ta;
  float b = *(float *)&tb;
  float c = powf(a, b);
  float d = pow(a, b);
  printf("inputs: a = %e b = %e\n", a, b);
  printf("actual    =\t%.7e\t(0x%08x)\n", c, *(unsigned *)&c);
  printf("expected  =\t%.7e\t(0x%08x)\n", d, *(unsigned *)&d);
  printf("pow(a, b) =\t%.13e\n", pow(a, b));
}

-- 
           Summary: powf inaccurate for some inputs
           Product: glibc
           Version: 2.3.2
            Status: NEW
          Severity: minor
          Priority: P3
         Component: math
        AssignedTo: aj at suse dot de
        ReportedBy: bob dot wilson at acm dot org
                CC: glibc-bugs at sources dot redhat dot com
  GCC host triplet: x86_64-redhat-linux


http://sources.redhat.com/bugzilla/show_bug.cgi?id=1161

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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