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/15735] New: IBM long double fmodl and remainerl errors


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

            Bug ID: 15735
           Summary: IBM long double fmodl and remainerl errors
           Product: glibc
           Version: 2.18
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: amodra at gmail dot com

IBM long double fmodl and remainderl return erroneous values in numerous cases.

Two such cases are demonstrated in the following testcase.  The first result
should be 0x1p-53 rather than 0x1.00000000000004p+0.  The second result should
be -0x1p-53 rather than -0.0.

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

int
main (void)
{
  long double x, y, z;
  union { long double ld; double d[2]; } u;

  x = 0x1.00000000000004p+0L;
  y = 0x1.fffffffffffff8p-1L;
  z = fmodl (x, y);

  u.ld = x;
  printf ("%24.21Lf %36La %21a %21a\n", u.ld, u.ld, u.d[0], u.d[1]);
  u.ld = y;
  printf ("%24.21Lf %36La %21a %21a\n", u.ld, u.ld, u.d[0], u.d[1]);
  u.ld = z;
  printf ("%24.21Lf %36La %21a %21a\n", u.ld, u.ld, u.d[0], u.d[1]);

  x = -0x1.00000000000004p+0L;
  y = 0x1.fffffffffffff8p-1L;
  z = fmodl (x, y);

  u.ld = x;
  printf ("%24.21Lf %36La %21a %21a\n", u.ld, u.ld, u.d[0], u.d[1]);
  u.ld = y;
  printf ("%24.21Lf %36La %21a %21a\n", u.ld, u.ld, u.d[0], u.d[1]);
  u.ld = z;
  printf ("%24.21Lf %36La %21a %21a\n", u.ld, u.ld, u.d[0], u.d[1]);

  return 0;
}

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