PATCH: BZ 552: Wrong return values for tgamma (0) and tgamma (-0)
Jakub Jelinek
jakub@redhat.com
Fri Nov 19 09:34:00 GMT 2004
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
More information about the Libc-alpha
mailing list