public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] libm/math: set errno to ERANGE at gamma poles Date: Wed, 5 Aug 2020 20:43:06 +0000 (GMT) [thread overview] Message-ID: <20200805204306.6FD843851C20@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=905aa4c01347b4a5deed8b96305f42eb7054d083 commit 905aa4c01347b4a5deed8b96305f42eb7054d083 Author: Keith Packard via Newlib <newlib@sourceware.org> Date: Tue Aug 4 15:22:20 2020 -0700 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> Diff: --- newlib/libm/math/w_gamma.c | 14 ++++---------- newlib/libm/math/w_lgamma.c | 13 ++++--------- newlib/libm/math/wf_gamma.c | 14 ++++---------- 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 }
reply other threads:[~2020-08-05 20:43 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200805204306.6FD843851C20@sourceware.org \ --to=corinna@sourceware.org \ --cc=newlib-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).