This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: PATCH: BZ 552: Wrong return values for tgamma (0) and tgamma (-0)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: GNU C Library <libc-alpha at sources dot redhat dot com>
- Date: Fri, 19 Nov 2004 10:31:37 +0100
- Subject: Re: PATCH: BZ 552: Wrong return values for tgamma (0) and tgamma (-0)
- References: <20041117015450.GA14753@lucon.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Nov 16, 2004 at 05:54:50PM -0800, H. J. Lu wrote:
> + case 50:
> + case 150:
> + case 250:
> + /* tgamma(|x|==0) */
> +#ifdef FE_INVALID
> + feclearexcept (FE_INVALID);
> +#endif
> + exc.type = SING;
> + exc.name = type < 100 ? "tgamma" : (type < 200
> + ? "tgammaf" : "tgammal");
> + exc.retval = 1.0/x;
This doesn't sound right to me.
If tgamma (+-0) is supposed to raise divide by zero exception, then
raising invalid exception, then clearing it and raising divide by
zero sounds wrong.
I'd say the right fix is to change sysdeps/ieee754/*/e_gamma*_r.c
to:
if (((hx & 0x7fffffff) | lx) == 0)
{
+ /* Return value for x == 0 is Inf with divide by zero exception. */
- /* Return value for x == 0 is NaN with invalid exception. */
*signgamp = 0;
+ return 1.0 / x;
- return x / x;
}
and remove
> +#ifdef FE_INVALID
> + feclearexcept (FE_INVALID);
> +#endif
and exc.retval setting here.
> + if (_LIB_VERSION == _POSIX_)
> + __set_errno (ERANGE);
> + else if (!matherr(&exc)) {
> + if (_LIB_VERSION == _SVID_) {
> + (void) WRITE2("tgamma: SING error\n", 18);
> + exc.retval = 1.0/x;
> + }
> + __set_errno (ERANGE);
> + }
> + break;
Jakub