[PATCH 1/2] Improve lgammaf range for very small cases

Andoni Arregi andoni.arregui@gtd-gmbh.de
Thu Feb 10 16:16:37 GMT 2022


Hi Corinna,

On Thu, 2022-02-10 at 15:58 +0100, Corinna Vinschen wrote:
> Hi Andoni,
> 
> On Feb  9 17:28, Andoni Arregi wrote:
> > The original cut for small arguments at |x|<2**-70 (copied from the
> > double version) produces that when computing nadj we get a subnormal
> > number for t*x and thus, the division of pi/subnormal will be INF and
> > the logarithm of it too, which is wrong as a result for lgammaf in this
> > range.
> > The proposed new limit seems to be safe and has been tested to
> > produce accurate results.
> > (Courtesy of Andreas Jung, ESA)
> > ---
> >  newlib/libm/math/erf_lgamma.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/newlib/libm/math/erf_lgamma.c
> > b/newlib/libm/math/erf_lgamma.c
> 
> This is broken.  It should be on one line, so apparently your
> mailer broke it via autowrapping lines.
> 
Thanks for letting me know. Now trying it again without autowrapping.
> > index f88f63092..84d02159b 100644
> > --- a/newlib/libm/math/erf_lgamma.c
> > +++ b/newlib/libm/math/erf_lgamma.c
> > @@ -168,7 +168,7 @@ static float zero=  0.0000000000e+00;
> >                *signgamp = -1;
> >            return one/(x-x);
> >         }
> > -       if(ix<0x1c800000) {     /* |x|<2**-70, return -log(|x|) */
> > +       if(ix<0x30800000) {     /* |x|<2**-30, return -log(|x|) */
> >            if(hx<0) {
> >                *signgamp = -1;
> >                return -__ieee754_logf(-x);
> > -- 
> > 2.35.1
> 
> But even if I fix this manually, your patch doesn't apply, neither with
> `git am', nor with `patch -p1'.  I have to admit that I don't understand
> why...
> 
I just checked `git am' myself before resubmitting. Hope it works now.
> Another question, would you mind to send patch series with a cover letter,
> please?
> 
Sure, sorry for that.
> 
> Thanks,
> Corinna

-- 
Andoni Arregi
Geschäftsführer
 
GTD GmbH
Ravensburger Str. 32a, 88677 Markdorf
T: +49 7544 96440 22 | M: +49 151 65620499 | F: +49 7544 96440 29
http://www.gtd-gmbh.de andoni.arregi@gtd-gmbh.de



More information about the Newlib mailing list