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/13824] New: exp2l(small_integer) produces rounding errors


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

             Bug #: 13824
           Summary: exp2l(small_integer) produces rounding errors
           Product: glibc
           Version: 2.8
            Status: NEW
          Severity: minor
          Priority: P2
         Component: math
        AssignedTo: unassigned@sourceware.org
        ReportedBy: bruno@clisp.org
    Classification: Unclassified


On Linux/SPARC, with glibc 2.7, exp2l(3.0L) needlessly introduces rounding
errors:
The exact value is 8.0L, the actual result is slightly smaller than 8.0L.

But the main purpose of the function exp2l() is to produce exact values for
small integers. Otherwise I could use
expl(x*0.693147180559945309417232121458176568075L).

In the other glibc ports, exp2l(3.0L) is actually an exact 8.0L.

How to reproduce:
====================== foo.c =================
#define _GNU_SOURCE 1
#include <math.h>
#include <stdio.h>
long double x = 3.0L;
int main ()
{
  long double y = exp2l (x);
  printf ("y = %.38Lf = %LA\n", y, y);
  return 0;
}
==============================================
$ gcc -m32 -Wall foo.c -lm

$ ./a.out 
y = 7.99999999999999999999999999999999845926 =
0X1.FFFFFFFFFFFFFFFFFFFFFFFFFFFEP+2

$ gcc -m64 -Wall foo.c -lm

$ ./a.out 
y = 7.99999999999999999999999999999999845926 =
0X1.FFFFFFFFFFFFFFFFFFFFFFFFFFFEP+2

Expected output:

y = 8.00000000000000000000000000000000000000 = 0X8P+0

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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]