git: 292815eac623 - main - Fix powf().

Mark Murray markm at FreeBSD.org
Mon Sep 6 17:53:01 UTC 2021


The branch main has been updated by markm:

URL: https://cgit.FreeBSD.org/src/commit/?id=292815eac623035493854f133200a4b1041fa246

commit 292815eac623035493854f133200a4b1041fa246
Author:     Mark Murray <markm at FreeBSD.org>
AuthorDate: 2021-09-06 17:26:39 +0000
Commit:     Mark Murray <markm at FreeBSD.org>
CommitDate: 2021-09-06 17:51:31 +0000

    Fix powf().
    
    Summary:
    From Steve Kargl:
    
    Paul Zimmermann has identified a bug in Openlibm's powf(),
    which is identical to FreeBSD's libm.  Both derived from
    fdlibm. https://github.com/JuliaMath/openlibm/issues/212.
    
    Consider
    
    % cat h.c
    int
    main(void)
    {
      float x, y, z;
      x =  0x1.ffffecp-1F;
      y = -0x1.000002p+27F;
      z =  0x1.557a86p115F;
      printf("%e %e %e <-- should be %e\n", x, y, powf(x,y), z);
      return 0;
    }
    
    % cc -o h -fno-builtin h.c -lm && ./h
    9.999994e-01 -1.342177e+08 inf <-- should be 5.540807e+34
    
    Reviewers: manu
    
    Subscribers: imp, andrew, emaste
    
    Differential Revision: https://reviews.freebsd.org/D31865
---
 lib/msun/src/e_powf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/msun/src/e_powf.c b/lib/msun/src/e_powf.c
index 33eedad50b16..122da455f740 100644
--- a/lib/msun/src/e_powf.c
+++ b/lib/msun/src/e_powf.c
@@ -136,7 +136,7 @@ __ieee754_powf(float x, float y)
     /* |y| is huge */
 	if(iy>0x4d000000) { /* if |y| > 2**27 */
 	/* over/underflow if x is not close to one */
-	    if(ix<0x3f7ffff7) return (hy<0)? sn*huge*huge:sn*tiny*tiny;
+	    if(ix<0x3f7ffff6) return (hy<0)? sn*huge*huge:sn*tiny*tiny;
 	    if(ix>0x3f800007) return (hy>0)? sn*huge*huge:sn*tiny*tiny;
 	/* now |1-x| is tiny <= 2**-20, suffice to compute
 	   log(x) by x-x^2/2+x^3/3-x^4/4 */


More information about the dev-commits-src-main mailing list