From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gtd-gmbh.de (mail.gtd.eu [46.24.46.35]) by sourceware.org (Postfix) with ESMTPS id 3EF4C3858C27 for ; Wed, 9 Feb 2022 13:57:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3EF4C3858C27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gtd-gmbh.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=gtd-gmbh.de X-MDAV-Result: clean X-MDAV-Processed: gtd-gmbh.de, Wed, 09 Feb 2022 14:52:12 +0100 Received: by gtd-gmbh.de (MDaemon PRO v21.0.3) with ESMTPSA id md5001016211959.msg; Wed, 09 Feb 2022 14:52:12 +0100 X-Spam-Processed: gtd-gmbh.de, Wed, 09 Feb 2022 14:52:12 +0100 (not processed: message from trusted or authenticated source) X-MDRemoteIP: 109.90.104.197 X-MDArrival-Date: Wed, 09 Feb 2022 14:52:12 +0100 X-Authenticated-Sender: andoni.arregui@gtd-gmbh.de X-Return-Path: prvs=1039b972d0=andoni.arregui@gtd-gmbh.de X-Envelope-From: andoni.arregui@gtd-gmbh.de X-MDaemon-Deliver-To: newlib@sourceware.org Message-ID: <6505c1b332ef8ecb9d9ea5900d7cb5a3a9cc767e.camel@gtd-gmbh.de> Subject: [PATCH] Fix expf overflow limit From: Andoni Arregi Reply-To: andoni.arregui@gtd-gmbh.de To: newlib@sourceware.org Date: Wed, 09 Feb 2022 14:52:07 +0100 In-Reply-To: References: Organization: GTD GmbH Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.3 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MDCFSigsAdded: gtd-gmbh.de X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Feb 2022 13:57:06 -0000 Correct the overflow limit in the variable o_threshold to be consistent with the FLT_UWORD_LOG_MAX variable used by the internal implementation of the expf algorithm itself. The u_threshold variable has also been modified to be written in the same format. Note that this fix improves the situation but does not completely correct the inconsistencies regarding the overflow and underflow limits between the expf wrapper (wf_exp.c) and the expf algorithm itself (ef_exp.c). Currently these limits are different for the _FLT_LARGEST_EXPONENT_IS_NORMAL and _FLT_NO_DENORMALS cases as well as for the case where __OBSOLETE_MATH is not defined (only for the underflow limit in this case). --- newlib/libm/math/wf_exp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/newlib/libm/math/wf_exp.c b/newlib/libm/math/wf_exp.c index 38cacd95a..075b5bb0a 100644 --- a/newlib/libm/math/wf_exp.c +++ b/newlib/libm/math/wf_exp.c @@ -26,8 +26,8 @@ static const float #else static float #endif -o_threshold= 8.8721679688e+01, /* 0x42b17180 */ -u_threshold= -1.0397208405e+02; /* 0xc2cff1b5 */ +o_threshold= 0x1.62e42ep+06, /* 0x42b17217 */ +u_threshold= -0x1.9fe36ap+06; /* 0xc2cff1b5 */ #ifdef __STDC__ float expf(float x) /* wrapper expf */ -- 2.35.1