diff options
author | Keith Packard via Newlib <newlib@sourceware.org> | 2020-08-05 01:22:20 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2020-08-05 23:16:31 +0300 |
commit | 905aa4c01347b4a5deed8b96305f42eb7054d083 (patch) | |
tree | 84fb97505d49e646afc939128febac454cd4c143 | |
parent | 50ad1980858b1092ebdd8c3dd6ae14d72596eb4d (diff) |
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>
-rw-r--r-- | newlib/libm/math/w_gamma.c | 14 | ||||
-rw-r--r-- | newlib/libm/math/w_lgamma.c | 13 | ||||
-rw-r--r-- | newlib/libm/math/wf_gamma.c | 14 | ||||
-rw-r--r-- | newlib/libm/math/wf_lgamma.c | 14 |
4 files changed, 16 insertions, 39 deletions
diff --git a/newlib/libm/math/w_gamma.c b/newlib/libm/math/w_gamma.c index cfded7b5d..b65d5cc4b 100644 --- a/newlib/libm/math/w_gamma.c +++ b/newlib/libm/math/w_gamma.c @@ -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 } diff --git a/newlib/libm/math/w_lgamma.c b/newlib/libm/math/w_lgamma.c index 25d12c9c7..c07804779 100644 --- a/newlib/libm/math/w_lgamma.c +++ b/newlib/libm/math/w_lgamma.c @@ -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 } diff --git a/newlib/libm/math/wf_gamma.c b/newlib/libm/math/wf_gamma.c index 0235ff4db..f0284a282 100644 --- a/newlib/libm/math/wf_gamma.c +++ b/newlib/libm/math/wf_gamma.c @@ -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 } diff --git a/newlib/libm/math/wf_lgamma.c b/newlib/libm/math/wf_lgamma.c index c644072e4..b232ecfe4 100644 --- a/newlib/libm/math/wf_lgamma.c +++ b/newlib/libm/math/wf_lgamma.c @@ -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 } |