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

Bug#210613: libc6.1: generic atan gives wrong results for some operands on alpha



Package: libc6.1
Version: 2.3.1-16
Severity: important

Consider the following program:

----------------------------------------------------------------------
#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: testatan <double>\n");
      exit (1);
    }

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

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

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

On an alpha machine, I get:

$ ./testatan 0.062510113344606447
      x = 0.062510113344606447    (mant: 4504328370650513/2^53, exp: -3)
atan(x) = 0.0081052752446468968   (mant: 4672373065155465/2^53, exp: -6)

$ ./testatan 1.016527294692847
      x = 1.016527294692847       (mant: 4578031945590644/2^53, exp: 1)
atan(x) = 0.081995669833819521    (mant: 5908410689753341/2^53, exp: -3)

$ ./testatan 1.9966212994203429
      x = 1.9966212994203429      (mant: 8991982940069452/2^53, exp: 1)
atan(x) = 1.797589501402598e-132  (mant: 5746301358148411/2^53, exp: -437)

Note: these are hard-to-round cases, i.e. atan(x) is very close to
the middle of two consecutive representable numbers.

The cos() function is also affected by the bug #153548 (fixed in libc6
2.3.2).

-- System Information
Debian Release: 3.0
Architecture: alpha
Kernel: Linux lepois 2.4.20 #3 Thu Apr 17 10:56:21 CEST 2003 alpha
Locale: LANG=POSIX, LC_CTYPE=en_US.ISO8859-1

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



Reply to: