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/15563] New: sincos() is incorrect for long double and large inputs on x86_64


http://sourceware.org/bugzilla/show_bug.cgi?id=15563

            Bug ID: 15563
           Summary: sincos() is incorrect for long double and large inputs
                    on x86_64
           Product: glibc
           Version: 2.18
            Status: NEW
          Keywords: glibc_2.15
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: carlos at redhat dot com
                CC: aj at suse dot de, bugdal at aerifal dot cx, carlos at redhat dot com,
                    ppluzhnikov at google dot com, vincent-srcware at vinc17 dot net
        Depends on: 13658
            Blocks: 13851, 13852, 13854

Still broken for long double on x86/x86_64.

Tested with current sources.

+++ This bug was initially created as a clone of Bug #13658 +++

sincos() is inaccurate for large inputs on x86_64: with glibc 2.13,

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

int main (void)
{
  volatile double x = 1.0e22;
  double s1, s2, c1;

  sincos (x, &s1, &c1);
  s2 = sin (x);
  printf ("s1 = %.17g\n", s1);
  printf ("s2 = %.17g\n", s2);
  return 0;
}

outputs:

s1 = 0.46261304076460175
s2 = -0.85220084976718879

(s2 is the correct value). I suppose that contrary to the other trig functions,
glibc uses the hardware sincos instruction, which has never been meant to be
used directly by a C library (the hardware elementary functions of the x86
processors were designed for small inputs, and they must not be used by code
where inputs can be large, like here). The sincos() function can simply be
implemented by a call to sin() and a call to cos() on this target.

Ditto for sincosf() and sincosl().

Note: x86 (32 bits) has the same problem, but it has been claimed that users
don't care about correctness on this target.

-- 
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]