Update.
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.

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).
This commit is contained in:
Ulrich Drepper 2004-11-21 19:58:34 +00:00
parent 250ecb48d5
commit 52495f29a2
10 changed files with 67 additions and 22 deletions

View file

@ -1,3 +1,24 @@
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.
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).
2004-11-20 Ulrich Drepper <drepper@redhat.com>
* time/tzfile.c (__tzfile_read): Avoid open for checking whether

View file

@ -4132,8 +4132,8 @@ tgamma_test (void)
START (tgamma);
TEST_f_f (tgamma, plus_infty, plus_infty);
TEST_f_f (tgamma, 0, nan_value, INVALID_EXCEPTION);
TEST_f_f (tgamma, minus_zero, nan_value, INVALID_EXCEPTION);
TEST_f_f (tgamma, 0, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
TEST_f_f (tgamma, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
/* tgamma (x) == NaN plus invalid exception for integer x <= 0. */
TEST_f_f (tgamma, -2, nan_value, INVALID_EXCEPTION);
TEST_f_f (tgamma, minus_infty, nan_value, INVALID_EXCEPTION);

View file

@ -39,8 +39,10 @@ static char rcsid[] = "$NetBSD: w_gamma.c,v 1.7 1995/11/20 22:06:43 jtc Exp $";
if(_LIB_VERSION == _IEEE_) return y;
if(!__finite(y)&&__finite(x)) {
if(__floor(x)==x&&x<=0.0)
return __kernel_standard(x,x,41); /* tgamma pole */
if (x == 0.0)
return __kernel_standard(x,x,50); /* tgamma pole */
else if(__floor(x)==x&&x<0.0)
return __kernel_standard(x,x,41); /* tgamma domain */
else
return __kernel_standard(x,x,40); /* tgamma overflow */
}

View file

@ -37,8 +37,11 @@ static char rcsid[] = "$NetBSD: w_gammaf.c,v 1.4 1995/11/20 22:06:48 jtc Exp $";
if(_LIB_VERSION == _IEEE_) return y;
if(!__finitef(y)&&__finitef(x)) {
if(__floorf(x)==x&&x<=(float)0.0)
if (x == (float)0.0)
/* tgammaf pole */
return (float)__kernel_standard((double)x,(double)x,150);
else if(__floorf(x)==x&&x<(float)0.0)
/* tgammaf domain */
return (float)__kernel_standard((double)x,(double)x,141);
else
/* tgammaf overflow */

View file

@ -42,8 +42,10 @@ static char rcsid[] = "$NetBSD: $";
if(_LIB_VERSION == _IEEE_) return y;
if(!__finitel(y)&&__finitel(x)) {
if(__floorl(x)==x&&x<=0.0)
return __kernel_standard(x,x,241); /* tgamma pole */
if(x==0.0)
return __kernel_standard(x,x,250); /* tgamma pole */
else if(__floorl(x)==x&&x<0.0)
return __kernel_standard(x,x,241); /* tgamma domain */
else
return __kernel_standard(x,x,240); /* tgamma overflow */
}

View file

@ -1,5 +1,5 @@
/* Implementation of gamma function according to ISO C.
Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
Copyright (C) 1997, 1999, 2001, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -35,9 +35,9 @@ __ieee754_gamma_r (double x, int *signgamp)
if (((hx & 0x7fffffff) | lx) == 0)
{
/* Return value for x == 0 is NaN with invalid exception. */
/* Return value for x == 0 is Inf with divide by zero exception. */
*signgamp = 0;
return x / x;
return 1.0 / x;
}
if (hx < 0 && (u_int32_t) hx < 0xfff00000 && __rint (x) == x)
{

View file

@ -1,5 +1,5 @@
/* Implementation of gamma function according to ISO C.
Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
Copyright (C) 1997, 1999, 2001, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -34,9 +34,9 @@ __ieee754_gammaf_r (float x, int *signgamp)
if ((hx & 0x7fffffff) == 0)
{
/* Return value for x == 0 is NaN with invalid exception. */
/* Return value for x == 0 is Inf with divide by zero exception. */
*signgamp = 0;
return x / x;
return 1.0 / x;
}
if (hx < 0 && (u_int32_t) hx < 0xff800000 && __rintf (x) == x)
{

View file

@ -90,6 +90,7 @@ static double zero = 0.0; /* used as const */
* 47-- exp10 underflow
* 48-- log2(0)
* 49-- log2(x<0)
* 50-- tgamma(+-0)
*/
@ -832,7 +833,7 @@ static double zero = 0.0; /* used as const */
case 40:
case 140:
case 240:
/* gamma(finite) overflow */
/* tgamma(finite) overflow */
exc.type = OVERFLOW;
exc.name = type < 100 ? "tgamma" : (type < 200
? "tgammaf" : "tgammal");
@ -846,7 +847,7 @@ static double zero = 0.0; /* used as const */
case 41:
case 141:
case 241:
/* gamma(-integer) or gamma(0) */
/* tgamma(-integer) */
exc.type = SING;
exc.name = type < 100 ? "tgamma" : (type < 200
? "tgammaf" : "tgammal");
@ -973,8 +974,24 @@ static double zero = 0.0; /* used as const */
__set_errno (EDOM);
}
break;
case 50:
case 150:
case 250:
/* tgamma(+-0) */
exc.type = SING;
exc.name = type < 100 ? "tgamma" : (type < 200
? "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);
__set_errno (ERANGE);
}
break;
/* #### Last used is 49/149/249 ### */
/* #### Last used is 50/150/250 ### */
}
return exc.retval;
}

View file

@ -1,5 +1,5 @@
/* Implementation of gamma function according to ISO C.
Copyright (C) 1997, 1999, 2002 Free Software Foundation, Inc.
Copyright (C) 1997, 1999, 2002, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz, 1999.
@ -36,9 +36,9 @@ __ieee754_gammal_r (long double x, int *signgamp)
if (((hx & 0x7fffffffffffffffLL) | lx) == 0)
{
/* Return value for x == 0 is NaN with invalid exception. */
/* Return value for x == 0 is Inf with divide by zero exception. */
*signgamp = 0;
return x / x;
return 1.0 / x;
}
if (hx < 0 && (u_int64_t) hx < 0xffff000000000000ULL && __rintl (x) == x)
{

View file

@ -1,5 +1,5 @@
/* Implementation of gamma function according to ISO C.
Copyright (C) 1997, 1999, 2001, 2003 Free Software Foundation, Inc.
Copyright (C) 1997, 1999, 2001, 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -34,9 +34,9 @@ __ieee754_gammal_r (long double x, int *signgamp)
if (((es & 0x7fff) | hx | lx) == 0)
{
/* Return value for x == 0 is NaN with invalid exception. */
/* Return value for x == 0 is Inf with divide by zero exception. */
*signgamp = 0;
return x / x;
return 1.0 / x;
}
if (es == 0xffffffff && ((hx & 0x7fffffff) | lx) == 0)
{