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: Don't modify __ieee754_pow return values in pow
Date: Wed,  5 Aug 2020 20:43:21 +0000 (GMT)	[thread overview]
Message-ID: <20200805204321.8CA65385703A@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e108d04432bb0c0c223c447fcead5f7605342cba

commit e108d04432bb0c0c223c447fcead5f7605342cba
Author: Keith Packard via Newlib <newlib@sourceware.org>
Date:   Tue Aug 4 15:22:23 2020 -0700

    libm/math: Don't modify __ieee754_pow return values in pow
    
    The __ieee754 functions already return the right value in exception
    cases, so don't modify those. Setting the library to _POSIX_/_IEEE_
    mode now only affects whether errno is modified.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>

Diff:
---
 newlib/libm/math/w_pow.c  | 14 +-------------
 newlib/libm/math/wf_pow.c | 14 +-------------
 2 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/newlib/libm/math/w_pow.c b/newlib/libm/math/w_pow.c
index d8556a170..cf6099cf4 100644
--- a/newlib/libm/math/w_pow.c
+++ b/newlib/libm/math/w_pow.c
@@ -68,14 +68,6 @@ PORTABILITY
 	double z;
 	z=__ieee754_pow(x,y);
 	if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
-	if(isnan(x)) {
-	    if(y==0.0) { 
-		/* pow(NaN,0.0) */
-		/* Not an error.  */
-                return 1.0;
-	    } else 
-		return z;
-	}
 	if(x==0.0){ 
 	    if(y==0.0) {
 		/* pow(0.0,0.0) */
@@ -93,20 +85,16 @@ PORTABILITY
 	        if(isnan(z)) {
 		    /* neg**non-integral */
 		    errno = EDOM;
-		    return 0.0/0.0;
 	        } else {
 		    /* pow(x,y) overflow */
 		    errno = ERANGE;
-		    if(x<0.0&&rint(y)!=y)
-		      return -HUGE_VAL;
-		    return HUGE_VAL;
                 }
+		return z;
 	    }
 	} 
 	if(z==0.0&&finite(x)&&finite(y)) {
 	    /* pow(x,y) underflow */
 	    errno = ERANGE;
-	    return 0.0;
         } 
 	return z;
 #endif
diff --git a/newlib/libm/math/wf_pow.c b/newlib/libm/math/wf_pow.c
index e551e6b48..e9babf67c 100644
--- a/newlib/libm/math/wf_pow.c
+++ b/newlib/libm/math/wf_pow.c
@@ -34,14 +34,6 @@
 	float z;
 	z=__ieee754_powf(x,y);
 	if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
-	if(isnan(x)) {
-	    if(y==0.0f) {
-		/* powf(NaN,0.0) */
-		/* Not an error.  */
-		return 1.0f;
-	    } else 
-		return z;
-	}
 	if(x==0.0f){
 	    if(y==0.0f) {
 		/* powf(0.0,0.0) */
@@ -61,20 +53,16 @@
 		    errno = EDOM;
 		    /* Use a float divide, to avoid a soft-float double
 		       divide call on single-float only targets.  */
-		    return 0.0f/0.0f;
 		} else {
 		    /* powf(x,y) overflow */
 		    errno = ERANGE;
-		    if(x<0.0f&&rintf(y)!=y)
-		      return -HUGE_VALF;
-		    return HUGE_VALF;
 		}
+		return z;
 	    }
 	} 
 	if(z==0.0f&&finitef(x)&&finitef(y)) {
 	    /* powf(x,y) underflow */
 	    errno = ERANGE;
-	    return 0.0f;
         }
 	return z;
 #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=20200805204321.8CA65385703A@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: link
Be 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).