From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5D4D13858D33; Mon, 4 Mar 2024 16:07:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D4D13858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1709568446; bh=8JS7gbdAAjjmW7Hjvqy1tO8kKA9bPuyOn//E9T9PgtM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xJ2R9ECZ/xUv5qutrzgIuD5SSq6OMAYDzzcNwf5G9Oc6IzS97WI1UkVhN8XRiN03F zjbmpn98szXNSJALby7Sv7qP8URn83c3cyiO+dHbS3+JJyor92YKprfWsc8SGqYL5L ywhDh0hjk6ny3cPGefzKzmX1/IDJzXo4BSLMCcPU= From: "wdijkstr at arm dot com" To: glibc-bugs@sourceware.org Subject: [Bug math/28472] pow(10, i) accuracy Date: Mon, 04 Mar 2024 16:07:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: math X-Bugzilla-Version: 2.31 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: wdijkstr at arm dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D28472 --- Comment #17 from Wilco --- (In reply to Vincent Lef=C3=A8vre from comment #16) > (In reply to Wilco from comment #15) > > GLIBC double precision pow is the most accurate of all libraries tested= at > > 0.523 ULP [1]. >=20 > What you forget is that this is the accuracy *tested* on arbitrary values. > The actual accuracy may be worse. And this is the case here, with an > accuracy larger than 1 ulp, according to the results in Comment #6! Please see the implementation - it documents the accuracy across the full i= nput ranges. The worst-case reported by random testing is slightly lower due to = not being able to test all input values. And comment #6 discusses exp10, which had a known ULP of 2.01 in previous GLIBCs. > > The new exp10 is also the most accurate of the 13 tested math libraries. > >=20 > > If you complain about inaccuracies in the most accurate library then ma= ybe > > your expectations are a little bit off... >=20 > In the present case, it may be far worse than the most accurate libraries > (well, it is difficult to say, due to the random tests). The result retur= ned > by glibc is not even faithfully rounded. So the user is right to complain, > even though there is no guarantee from the ISO C standard. No, it's not difficult to say. We computed the accuracy and have *documente= d* it in the source code. So it's not only not a "guess", it's actually imposs= ible to get cases that are worse. Ie. if we have an algorithm that does < 0.55ULP before rounding, we can't ever get a 2 ULP error. > > The fact is, binary floating point cannot represent all powers of 10. I= f you > > don't like the rounding behaviour of floating point, don't use floating > > point. >=20 > Don't blame floating point if this is a poor implementation. Even the old exp10 wasn't disastrously bad like j0/j1/y0/y0/tgamma. > > Note compilers optimize pow (C, x) into exp (x * log (C)) with -Ofast. > > However if C is a multiple of 2 or 10, we could use exp2 or exp10 for > > slightly better accuracy. >=20 > I suppose that you mean "if C is a *power* of 2 or 10". Correct. --=20 You are receiving this mail because: You are on the CC list for the bug.=