This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: BZ 552: Wrong return values for tgamma (0) and tgamma (-0)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]