Re: Fw: [PATCH 0/3] libm: Clean up gamma functions
Keith Packard via Newlib <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
C Howland via Newlib <[email protected]> writes: >> Following the C spec, gamma(-0) should be -INFINITY rather than >> +INFINITY, so the *signgamp value in lgamma should be -1 >> rather than +1 for this case. >> > What C spec? Neither C99 nor C11 say so that I see for lgamma(). POSIX > makes the direct statement "If x is a non-positive integer, a pole error > shall occur and lgamma(), lgammaf(), and lgammal() shall return +HUGE_VAL, > +HUGE_VALF, and +HUGE_VALL, respectively." 0, regardless of sign, falls > under that. Right, C99/C11 doesn't mention signgam at all, so POSIX is free to define it as it likes. That spec only says that it's value is undefined when the parameter is a negative integer. C99 says that , tgamma should return -INFINITY for -0. As newlib makes 'gamma' an alias for tgamma, gamma should probably return the same thing. To make that work with our implementation of tgamma, (which uses lgamma and the 'signgam' value), that signgam value should be -1. > https://pubs.opengroup.org/onlinepubs/9699919799/functions/lgamma.html > Additionally, the Linux lgamma man page, using GLIBC, says the same thing > as quoted from POSIX (not word for word, but the identical result). > (POSIX does require the +-0 +-INFINITY for tgamma(). Did these get crossed > up?) > Craig I think we're probably just confusing gamma between lgamma and tgamma -- newlib defines gamma 'oddly' (fixed in 2/3). I think the only problematic patch in the series is in changing the semantics of gamma/gammaf and removing the gamma_r/gammaf_r -- we need to decide how to recover from what looks like a mistake introduced 18 years ago. -- -keith
signature.asc
(application/pgp-signature, 832 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAl9ISNsACgkQ2yIaaQAA ABFK5Q//dJi6k9JSKRZu3Gh/o6EC+x17LfGlgYtsKN67fUvdOkGC0TwTdJpoxm5t 2nY33EH4R0efXw8eQRlsMh+8I3GA/mlOujPIgc4U9PUiwv98Gmqi7sOuQHQi0D9i e334CsWt7amNXlS10nwSHFgCCngRSFP4JWcqIznOXMDPiFK472fLwVw1OdVSYq7j 60J9kQi9Q/0iVt1xzczdtooWvkdXkfPVZIFW8oD1I7khgjsTpidjJK6Gh/LMjROq ynrvMmoFI1fqV49AOsfTsNQTV0vlgehxFC+pds5YCn8/q4GOC1XCXD9T4fdKIOaI NjNYERVCL/fPUxtx7AfOWnYb66wj9NWFXMZ7rdL++F50+vMj3qd2pWoybQVUQ8L9 mbCrvHdPO1mxSk43KT38NJ0LHJ/AecNslLbN+f8iZkQ04XGy1T/AzRd3Cj5BeAsk /B4H1w5MWUSPIispbKF0kqYzaIwL0jX9SXxkGwOg+k01pFZHXG0AaaEWPRLle1Rp BWBENqFagpSDoolKKypXk+fgzEZTJu1cjIqUiDv5imcY0BtDMwj3haBdJfkradE4 rIHPVudMc3gSj3PcnbIu1sfZ5PTDY6pKBKZK0dM4OzZ8TVZSl0ZsbkEY0qoFvpR5 AmcE7kwkI2HhpykkfaSX5bsA2ZZ3/Yw7OC3x5L96Su+p2446Sr8= =ZFVl -----END PGP SIGNATURE-----