libm/math: set errno to ERANGE at gamma poles

For POSIX, gamma(i) (i non-positive integer) should set errno to
ERANGE instead of EDOM.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard via Newlib 2020-08-04 15:22:20 -07:00 committed by Corinna Vinschen
parent 50ad198085
commit 905aa4c013
4 changed files with 16 additions and 39 deletions

View File

@ -155,16 +155,10 @@ in terms of the base return values, although the <[signgam]> global for
y = __ieee754_gamma_r(x,&(_REENT_SIGNGAM(_REENT))); y = __ieee754_gamma_r(x,&(_REENT_SIGNGAM(_REENT)));
if(_LIB_VERSION == _IEEE_) return y; if(_LIB_VERSION == _IEEE_) return y;
if(!finite(y)&&finite(x)) { if(!finite(y)&&finite(x)) {
if(floor(x)==x&&x<=0.0) { /* gamma(finite) overflow */
/* gamma(-integer) or gamma(0) */ errno = ERANGE;
errno = EDOM; }
} else { return y;
/* gamma(finite) overflow */
errno = ERANGE;
}
return HUGE_VAL;
} else
return y;
#endif #endif
} }

View File

@ -38,15 +38,10 @@
y = __ieee754_lgamma_r(x,&(_REENT_SIGNGAM(_REENT))); y = __ieee754_lgamma_r(x,&(_REENT_SIGNGAM(_REENT)));
if(_LIB_VERSION == _IEEE_) return y; if(_LIB_VERSION == _IEEE_) return y;
if(!finite(y)&&finite(x)) { if(!finite(y)&&finite(x)) {
if(floor(x)==x&&x<=0.0) /* lgamma(finite) overflow */
/* lgamma(-integer) */ errno = ERANGE;
errno = EDOM; }
else return y;
/* lgamma(finite) overflow */
errno = ERANGE;
return HUGE_VAL;
} else
return y;
#endif #endif
} }

View File

@ -32,16 +32,10 @@
y = __ieee754_gammaf_r(x,&(_REENT_SIGNGAM(_REENT))); y = __ieee754_gammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
if(_LIB_VERSION == _IEEE_) return y; if(_LIB_VERSION == _IEEE_) return y;
if(!finitef(y)&&finitef(x)) { if(!finitef(y)&&finitef(x)) {
if(floorf(x)==x&&x<=0.0f) { /* gammaf(finite) overflow */
/* gammaf(-integer) or gammaf(0) */ errno = ERANGE;
errno = EDOM; }
} else { return y;
/* gammaf(finite) overflow */
errno = ERANGE;
}
return HUGE_VALF;
} else
return y;
#endif #endif
} }

View File

@ -32,16 +32,10 @@
y = __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT))); y = __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
if(_LIB_VERSION == _IEEE_) return y; if(_LIB_VERSION == _IEEE_) return y;
if(!finitef(y)&&finitef(x)) { if(!finitef(y)&&finitef(x)) {
if(floorf(x)==x&&x<=0.0f) { /* lgammaf(finite) overflow */
/* lgammaf(-integer) */ errno = ERANGE;
errno = EDOM; }
} else { return y;
/* lgammaf(finite) overflow */
errno = ERANGE;
}
return HUGE_VALF;
} else
return y;
#endif #endif
} }