From: Paul Zimmermann <Paul.Zimmermann@inria.fr>
To: andoni.arregui@gtd-gmbh.de
Cc: newlib@sourceware.org
Subject: Re: [PATCH] Fix expf overflow limit
Date: Thu, 10 Feb 2022 16:38:08 +0100 [thread overview]
Message-ID: <mwr18ad95r.fsf@tomate.loria.fr> (raw)
In-Reply-To: <6505c1b332ef8ecb9d9ea5900d7cb5a3a9cc767e.camel@gtd-gmbh.de> (message from Andoni Arregi on Wed, 09 Feb 2022 14:52:07 +0100)
Dear Andoni,
I confirm that this fixes the expf large errors. With commit 8f2bd6f I now get
a maximal error of 0.911 ulps:
Checking exp with newlib-4.2.0.20211231
Using RedHat newlib
MPFR library: 4.1.0
MPFR header: 4.1.0 (based on 4.1.0)
Checking function expf with MPFR_RNDN
libm wrong by up to 9.11e-01 ulp(s) [1] for x=-0x1.2e35b6p+5
exp gives 0x1.6a2544p-55
mpfr_exp gives 0x1.6a2546p-55
Total: errors=17982848 (0.42%) errors2=0 maxerr=9.11e-01 ulp(s)
Thank you,
Paul
PS: in this case and in the two other issues I reported (about lgammaf and tgammaf),
I have to apologize. This was not a regression in Newlib 4.2.0, but a bug in our
checking program which did not report such issues. With the new version of our
program, we get similar results with Newlib 4.1.0 and Newlib 4.2.0.
> From: Andoni Arregi <andoni.arregui@gtd-gmbh.de>
> Cc: Paul Zimmermann <Paul.Zimmermann@inria.fr>
> Date: Wed, 09 Feb 2022 14:52:07 +0100
> Organization: GTD GmbH
> User-Agent: Evolution 3.42.3
>
> 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
>
>
next prev parent reply other threads:[~2022-02-10 15:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 4:36 regression in Newlib 4.2.0 Paul Zimmermann
2022-02-09 13:52 ` [PATCH] Fix expf overflow limit Andoni Arregi
2022-02-10 15:01 ` Corinna Vinschen
2022-02-10 15:38 ` Paul Zimmermann [this message]
2022-02-09 14:27 ` regression in Newlib 4.2.0 Andoni Arregi
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=mwr18ad95r.fsf@tomate.loria.fr \
--to=paul.zimmermann@inria.fr \
--cc=andoni.arregui@gtd-gmbh.de \
--cc=newlib@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: link
Be 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).