Re: Fw: [PATCH 3/3] libm: Adjust errno/exception values for gamma/lgamma

C Howland via Newlib <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CANk6obTZtC8g9u4d+71JoFOBdmJ65tMNciwv7WNtypKhPgBe5g@mail.gmail.com>
> ------------------------------
> *From:* Newlib <[email protected]> on behalf of Keith Packard
> via Newlib <[email protected]>
> *Sent:* Wednesday, August 26, 2020 1:03 PM
> *To:* [email protected] <[email protected]>
> *Subject:* [PATCH 3/3] libm: Adjust errno/exception values for
> gamma/lgamma
>
>
>
>
> This makes all of gamma/lgamma functions match POSIX (and glibc) for
> errno and exception values for both gamma and lgamma functions.
>
> The big change is to support the exception/errno value differences for
> tgamma/lgamma for negative integer arguments. tgamma produces
> EDOM/FE_INVALID while lgamma produces ERANGE/FE_DIVBYZERO.
>
> This was done by splitting the lowest level __ieee754_lgamma*_r
> functions apart. The new lower-level ___ieee754_lgamma*_r functions
> can now produce exceptions which are correct for either lgamma or
> tgamma and use the value in the signgamp parameter to select which
> mode to operate in.
>
> All functions now return EDOM/FE_INVALID for -INFINITY, although POSIX
> doesn't specify this behavior for lgamma. It does match glibc at
> least.
>
I think you're looking at an old GLIBC.  From my RHEL7 lgamma() man  page:
"       If the result overflows, a range error occurs, and the functions
return
       HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the correct
math‐
       ematical sign.
...
BUGS
       In glibc 2.9 and earlier, when a pole error occurs,  errno  is  set
 to
       EDOM;  instead of the POSIX-mandated ERANGE.  Since version 2.10,
glibc
       does the right thing."
POSIX has only pole and range errors listed for lgamma(), both of which
return ERANGE, so it is definitely improper to return EDOM.  It should be
range, so ERANGE/FE_OVERFLOW is what it ought to be.

>
> Signed-off-by: Keith Packard <[email protected]>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.