[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#210400: libc6: generic log() is no longer exactly rounded (regression)



Package: libc6
Version: 2.3.2-5
Severity: normal

(Filled as a normal bug since it is a regression.)

With libc6 2.3.1-16, the generic log() function (as used on the PowerPC)
seemed to be exactly rounded. This is no longer the case with 2.3.2-5
(see the test below, which worked with libc6 2.3.1-16).

I couldn't see anything about this problem in the changelog except:

2002-10-25  Roland McGrath  <roland@redhat.com>

        * math/math.h (M_LOG2El): Correct the value.
        From Stephen L Moshier <steve@moshier.net>.

but I don't know if this change is the cause of the regression.

File testlog.c:
------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void out (double x, char *s)
{
  int exp;
  long long m;

  m = frexp (x, &exp) * 9007199254740992LL;
  printf ("%s = %-23.17g (mant: %lld/2^53, exp: %d)\n", s, x, m, exp);
}

int main (int argc, char *argv[])
{
  double x, y;

  if (argc != 2)
    {
      fprintf (stderr, "Usage: testlog <double>\n");
      exit (1);
    }

  x = atof (argv[1]);
  y = log (x);

  out (x, "     x");
  out (y, "log(x)");

  return 0;
}
------------------------------------------------------------------------

$ ./testlog 1.000000046697654
     x = 1.000000046697654       (mant: 4503599837678033/2^53, exp: 1)
log(x) = 4.6697652875585992e-08  (mant: 7056749784587155/2^53, exp: -24)

Maple gives:

> Digits := 40;
                                 Digits := 40

> evalf(log(4503599837678033/2^52)*2^(77));
                                                             16
                0.7056749784587155500000005883462666272941 10

The result is closer to 7056749784587156/2^53 than 7056749784587155/2^53.
So, log(x) should have returned a number equal to 7056749784587156/2^53.

-- System Information:
Debian Release: testing/unstable
Architecture: powerpc
Kernel: Linux ay 2.4.18-newpmac #1 Mon Jun 9 03:10:07 UTC 2003 ppc
Locale: LANG=C, LC_CTYPE=en_US.ISO8859-1

Versions of packages libc6 depends on:
ii  libdb1-compat                 2.1.3-7    The Berkeley database routines [gl

-- no debconf information



Reply to: