Message ID | 20240911140646.2143-4-fabian.schriever@gtd-gmbh.de |
---|---|
State | New |
Headers |
Return-Path: <newlib-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D033385E833 for <patchwork@sourceware.org>; Wed, 11 Sep 2024 14:13:20 +0000 (GMT) X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from gtd-gmbh.de (mail.gtd.eu [46.24.46.35]) by sourceware.org (Postfix) with ESMTPS id 6F212385DDDD for <newlib@sourceware.org>; Wed, 11 Sep 2024 14:11:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F212385DDDD Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gtd-gmbh.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gtd-gmbh.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6F212385DDDD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=46.24.46.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726063919; cv=none; b=Y7ebq2OZSKRsIiyRGN0VvFd64COeBLG4NvB3KL0ZPq0mHmhFo8pRFSUwqQqNxhGocnrKpqc6D1OKNG3a3Emt70v5e5rEIxQn8NwPF1RwlPPU7HzgM7otlit2+x2EB8jsYQi8IVexz/9SZoBgDyIXruYrpVoG9HNxMI4J9UVpyn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726063919; c=relaxed/simple; bh=+NKy76UMiKR6OGqtd0MYPJn9L77AVlj/B5zeVeudeo8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=PUYgCP7sokX3ODAKfAIqpiALQWI7DROutWHAXxEJzVyyeXyD8XrdlSyWlkTNQ1IbGu5GfXXK01GUH/kJ7ULHXPk79aeDEeSt9FAPwrzoiiyRD4nWk0tqSAEWZ0Y7lAU1wIylCigmo7H1J1T0GrWXHcKZzpjdxoLac1WIeikGhNc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=gtd-gmbh.de; s=nk2048220908; t=1726063722; x=1726668522; i=fabian.schriever@gtd-gmbh.de; q=dns/txt; h=From:To:Cc:Subject: Date:Message-Id:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=+NKy76UMiKR6OGqtd0MYPJn9L77AVlj/B5 zeVeudeo8=; b=qwxowpLfKaH1smLNUPGNsFM4m8Vx6+lxHgAOXzZaQSDxrd0vu3 xLOaYM2a8i5ggQtqvP4y1+WFXC0jIqqOzc7RT3u91ykYX0Pa50Qg7yWEkhYBEBrX 0zvSyo0b264YqK/3lPz51h3PGxYD9ldWff+PWkjgUYQeW7BWSe1IRRgRWSL9FtIW 7CL8A7e64oakM3hBIBbVLRqDbTFZVgljYs2Cn3Ku2McddQ6yZsViBty7baUY8P3b auGpCYX7RO/Ufb5KFiZ9CRaAYATqZp9z/KuaBS4OlNvy+fgL8Y9UQTsmmCWnZCOe 3I7bS36CUMiJYH5c6HoL6wBgrYVQKcWW25Tg== X-MDAV-Result: clean X-MDAV-Processed: gtd-gmbh.de, Wed, 11 Sep 2024 16:08:42 +0200 Received: from localhost.localdomain [(95.223.184.231)] by gtd-gmbh.de (MDaemon PRO v24.0.1) with ESMTPSA id md5001020706856.msg; Wed, 11 Sep 2024 16:08:40 +0200 X-Spam-Processed: gtd-gmbh.de, Wed, 11 Sep 2024 16:08:40 +0200 (not processed: message from trusted or authenticated source) X-MDRemoteIP: 95.223.184.231 X-MDHelo: localhost.localdomain X-MDArrival-Date: Wed, 11 Sep 2024 16:08:40 +0200 X-Authenticated-Sender: fabian.schriever@gtd-gmbh.de X-Return-Path: prvs=19845911f7=fabian.schriever@gtd-gmbh.de X-Envelope-From: fabian.schriever@gtd-gmbh.de X-MDaemon-Deliver-To: newlib@sourceware.org From: Fabian Schriever <fabian.schriever@gtd-gmbh.de> To: newlib@sourceware.org Cc: Paul.Zimmermann@inria.fr, Fabian Schriever <fabian.schriever@gtd-gmbh.de> Subject: [PATCH 3/3] powf: Fixed another precision bug in powf() (FreeBSD) Date: Wed, 11 Sep 2024 16:06:46 +0200 Message-Id: <20240911140646.2143-4-fabian.schriever@gtd-gmbh.de> X-Mailer: git-send-email 2.33.0.windows.1 In-Reply-To: <20240911140646.2143-1-fabian.schriever@gtd-gmbh.de> References: <20240911140646.2143-1-fabian.schriever@gtd-gmbh.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MDCFSigsAdded: gtd-gmbh.de X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org |
Series |
Fix powf inaccuracies up to ~169 ULP reported by Paul Zimmermann
|
|
Commit Message
Fabian Schriever
Sept. 11, 2024, 2:06 p.m. UTC
Fixed another precision bug in powf(). This one is in the computation [t=p_l+p_h High]. We multiply t by lg2_h, and want the result to be exact. For the bogus float case of the high-low decomposition trick, we normally discard the lowest 12 bits of the fraction for the high part, keeping 12 bits of precision. That was used for t here, but it doesnt't work because for some reason we only discard the lowest 9 bits in the fraction for lg2_h. Discard another 3 bits of the fraction for t to compensate. This bug gave wrong results like: powf(0.9999999, -2.9999995) = 1.0000002 (should be 1.0000001) hex values: 3F7FFFFF C03FFFFE 3F800002 3F800001 As explained in the log for the previous commit, the bug is normally masked by doing float calculations in extra precision on i386's, but is easily detected by ucbtest on systems that don't have accidental extra precision. Reference: https://github.com/freebsd/freebsd-src/commit/5f20e5ce7f396ad064bfc1f45b8075ea1c0580f9 Original Author: Bruce Evans --- newlib/libm/math/ef_pow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/newlib/libm/math/ef_pow.c b/newlib/libm/math/ef_pow.c index c7b1975c3..8cf58dbb5 100644 --- a/newlib/libm/math/ef_pow.c +++ b/newlib/libm/math/ef_pow.c @@ -242,7 +242,7 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/ } t = p_l+p_h; GET_FLOAT_WORD(is,t); - SET_FLOAT_WORD(t,is&0xfffff000); + SET_FLOAT_WORD(t,is&0xffff8000); u = t*lg2_h; v = (p_l-(t-p_h))*lg2+t*lg2_l; z = u+v;