public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/30181] New: Imprecise result from asinhl on IBM 128-bit long double
@ 2023-02-28 17:23 marcus at mc dot pp.se
  0 siblings, 0 replies; only message in thread
From: marcus at mc dot pp.se @ 2023-02-28 17:23 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=30181

            Bug ID: 30181
           Summary: Imprecise result from asinhl on IBM 128-bit long
                    double
           Product: glibc
           Version: 2.36
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: marcus at mc dot pp.se
  Target Milestone: ---

Created attachment 14723
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14723&action=edit
Patch to fix precision loss in sysdeps/ieee754/ldbl-128ibm/s_asinhl.c

When running the following program on ppc64 with IBM long double ABI:

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

int main(int argc, char *argv[])
{
  long double x = 13.7L;

  printf("Expected  : 3.31187234356338694815\n");
  printf("Function  : %.20Lf\n", asinhl(x));
  printf("Definition: %.20Lf\n", logl(sqrtl(x*x+1.0L)+x));

  return 0;
}
---8<---

the result is:

---8<---
hakua:~% /tmp/asinhl_test
Expected  : 3.31187234356338694815
Function  : 3.31187234356338689639
Definition: 3.31187234356338694815
hakua:~% 
---8<---

Note that the last 4 digits printed are wrong when using the asinhl function,
but correct when using the definition of asinh.

The error is because the implementation uses fabs instead of fabsl in one
place,
causing the loss of precision.

After changing the call to fabs into a call to fabsl, the program works
correctly:

---8<---
hakua:~% /tmp/asinhl_test
Expected  : 3.31187234356338694815
Function  : 3.31187234356338694815
Definition: 3.31187234356338694815
hakua:~% 
---8<---

I'm attaching the patch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-28 17:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28 17:23 [Bug math/30181] New: Imprecise result from asinhl on IBM 128-bit long double marcus at mc dot pp.se

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).