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:
parent
b6cedcd9a4
commit
2daeea8884
|
@ -155,15 +155,9 @@ 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(-integer) or gamma(0) */
|
|
||||||
errno = EDOM;
|
|
||||||
} else {
|
|
||||||
/* gamma(finite) overflow */
|
/* gamma(finite) overflow */
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
}
|
}
|
||||||
return HUGE_VAL;
|
|
||||||
} else
|
|
||||||
return y;
|
return y;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,14 +38,9 @@
|
||||||
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(-integer) */
|
|
||||||
errno = EDOM;
|
|
||||||
else
|
|
||||||
/* lgamma(finite) overflow */
|
/* lgamma(finite) overflow */
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
return HUGE_VAL;
|
}
|
||||||
} else
|
|
||||||
return y;
|
return y;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,15 +32,9 @@
|
||||||
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(-integer) or gammaf(0) */
|
|
||||||
errno = EDOM;
|
|
||||||
} else {
|
|
||||||
/* gammaf(finite) overflow */
|
/* gammaf(finite) overflow */
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
}
|
}
|
||||||
return HUGE_VALF;
|
|
||||||
} else
|
|
||||||
return y;
|
return y;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,15 +32,9 @@
|
||||||
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(-integer) */
|
|
||||||
errno = EDOM;
|
|
||||||
} else {
|
|
||||||
/* lgammaf(finite) overflow */
|
/* lgammaf(finite) overflow */
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
}
|
}
|
||||||
return HUGE_VALF;
|
|
||||||
} else
|
|
||||||
return y;
|
return y;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue