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 Fri, Nov 19, 2004 at 09:12:29AM -0800, H. J. Lu wrote:
> Here is the updated patch.

> 2004-11-19  H.J. Lu  <hongjiu.lu@intel.com>
> 
> 	[BZ #552]
> 	* math/libm-test.inc (tgamma_test): Update tgamma (0) and
> 	tgamma (-0).
> 
> 	* sysdeps/generic/w_tgamma.c (__tgamma): Properly handle
> 	|x| == 0.
> 	* sysdeps/generic/w_tgammaf.c (__tgammaf): Likewise.
> 	* sysdeps/generic/w_tgammal.c (__tgammal): Likewise.
> 	* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r): Likewise.
> 	* sysdeps/ieee754/flt-32/e_gammaf_r.c: Likewise.
> 	* sysdeps/ieee754/ldbl-128/e_gammal_r.c: Likewise.
> 	* sysdeps/ieee754/ldbl-96/e_gammal_r.c: Likewise.
> 
> 	* sysdeps/ieee754/k_standard.c (__kernel_standard): Handle
> 	tgamma (0) and tgamma (-0).

Looks good, but I'd avoid raising the divide by zero exception again
unnecessarily.  On top of your patch:

2004-11-20  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/ieee754/k_standard.c: Document code 50.
	(__kernel_standard) <case 50>: Avoid raising div-by-zero
	exception again.

--- libc/sysdeps/ieee754/k_standard.c.jj	2004-11-20 22:24:03.083902299 +0100
+++ libc/sysdeps/ieee754/k_standard.c	2004-11-20 22:20:51.704063373 +0100
@@ -90,6 +90,7 @@ static double zero = 0.0;	/* used as con
  *	47-- exp10 underflow
  *	48-- log2(0)
  *	49-- log2(x<0)
+ *	50-- tgamma(+-0)
  */
 
 
@@ -976,18 +977,16 @@ static double zero = 0.0;	/* used as con
 	    case 50:
 	    case 150:
 	    case 250:
-		/* tgamma(|x|==0) */
+		/* tgamma(+-0) */
 		exc.type = SING;
 		exc.name = type < 100 ? "tgamma" : (type < 200
-						   ? "tgammaf" : "tgammal");
-		exc.retval = 1.0/x;
+						    ? "tgammaf" : "tgammal");
+		exc.retval = __copysign (HUGE_VAL, x);
 		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;
-		      }
+		  if (_LIB_VERSION == _SVID_)
+		    (void) WRITE2("tgamma: SING error\n", 18);
 		  __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]