public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "marcus at mc dot pp.se" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug math/30181] New: Imprecise result from asinhl on IBM 128-bit long double Date: Tue, 28 Feb 2023 17:23:16 +0000 [thread overview] Message-ID: <bug-30181-131@http.sourceware.org/bugzilla/> (raw) 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.
reply other threads:[~2023-02-28 17:23 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-30181-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).