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)));
if(_LIB_VERSION == _IEEE_) return y;
if(!finite(y)&&finite(x)) {
if(floor(x)==x&&x<=0.0) {
/* gamma(-integer) or gamma(0) */
errno = EDOM;
} else {
/* gamma(finite) overflow */
errno = ERANGE;
}
return HUGE_VAL;
} else
return y;
/* gamma(finite) overflow */
errno = ERANGE;
}
return y;
#endif
}

View File

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

View File

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

View File

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