Bug 1161 - powf inaccurate for some inputs
Summary: powf inaccurate for some inputs
Status: RESOLVED DUPLICATE of bug 14759
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.3.2
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
: 3407 (view as bug list)
Depends on:
Reported: 2005-08-03 17:31 UTC by Bob Wilson
Modified: 2019-04-10 10:05 UTC (History)
3 users (show)

See Also:
Host: x86_64-redhat-linux
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Bob Wilson 2005-08-03 17:31:15 UTC
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));
Comment 1 Ulrich Drepper 2005-10-15 23:47:25 UTC
Once somebody provides a better implementation we can use it.
Comment 2 Vincent Lefèvre 2009-09-24 08:03:35 UTC
FYI, this is similar to bug 706 (on pow() inaccuracies, which are particularly
visible for x ~ 1.0).
Comment 3 Vincent Lefèvre 2009-09-24 08:12:04 UTC
*** Bug 3407 has been marked as a duplicate of this bug. ***
Comment 4 Joseph Myers 2012-02-22 21:48:24 UTC
Still present, should be added to the testsuite.
Comment 5 Joseph Myers 2012-10-24 12:42:06 UTC
Collecting all reports of few-ulps errors together in one meta-bug.

*** This bug has been marked as a duplicate of bug 14759 ***