From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 5C892386F45F for ; Fri, 11 Dec 2020 21:03:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5C892386F45F Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-ESRkCU2oMy2S3gGFzF3wMg-1; Fri, 11 Dec 2020 16:02:55 -0500 X-MC-Unique: ESRkCU2oMy2S3gGFzF3wMg-1 Received: by mail-pg1-f199.google.com with SMTP id q4so7354137pgn.0 for ; Fri, 11 Dec 2020 13:02:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=L1v3+HYw92r3K5weRukXRvBhNto2qPJyRh9KcB5Nl2c=; b=G73seFw27YeYeOupBwKWizE6suCPvlwLc+8wz0F9ZEdXKRQWltls4YyQyYsNOT4Iag Ghz50Gwf7XRBeavopsH8IXljKc6qUsKxGyR7CtLzJrOFROVow2+9qBdTX0SPSgEA31yC EOiSraaDh5q5dWiVd/trNvTKte9WXEoULNilKTMtHZCJyt7LzU9uxCpsl3idfVNuNBOT 5r0i1Nzd4yjJHUpVYM2klUELDiSTdQX2Px3VXe+rYU3CRghV9OboNiL/ic4guEv8R54T eOIg3pAgcsNT5+OqdrcNGT2V5AlwV085g25uFjjjRROCFsOT96u2WN0nxWR4PC84vzuu Rltw== X-Gm-Message-State: AOAM531lhkfPGHzJwZt7JJaaxXCMEaDOv3GrTpXIkY3cNgwUAa1z14x1 qENqKDxScZkFBaVSV8l6pvdgtZzRP17CCLYbu0yzniTYt1kAtKogI+XAR0H5UofDwsjQ1pwgaDd Cum93sh9bf9/VkhCC7pX5SR6pzxCPUuA= X-Received: by 2002:a17:90b:3110:: with SMTP id gc16mr14750619pjb.83.1607720573915; Fri, 11 Dec 2020 13:02:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxx65IQtxAFDQeiY9wYobnCMU3cFm1llr9tKi8bK4kZWuAlvIqp3FyRlnNPWn1QOusTHn2cHSt7zrXwr1EVMB0= X-Received: by 2002:a17:90b:3110:: with SMTP id gc16mr14750600pjb.83.1607720573607; Fri, 11 Dec 2020 13:02:53 -0800 (PST) MIME-Version: 1.0 References: <20201211155735.2645-1-fabian.schriever@gtd-gmbh.de> In-Reply-To: <20201211155735.2645-1-fabian.schriever@gtd-gmbh.de> From: Jeff Johnston Date: Fri, 11 Dec 2020 16:02:42 -0500 Message-ID: Subject: Re: [PATCH] Fix error in powf for x close to 1 and large y To: Fabian Schriever Cc: Newlib X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Dec 2020 21:03:01 -0000 Thanks Fabian. Patch applied. Supplied sample powf call above tested against glibc and newlib with/without patch. -- Jeff J. On Fri, Dec 11, 2020 at 11:02 AM Fabian Schriever < fabian.schriever@gtd-gmbh.de> wrote: > This patch fixes the error found by Paul Zimmermann (see > https://homepages.loria.fr/PZimmermann/papers/#accuracy) regarding x > close to 1 and rather large y (specifically he found the case > powf(0x1.ffffeep-1,-0x1.000002p+27) which returns +Inf instead of the > correct value). We found 2 more values for x which show the same faulty > behaviour, and all 3 are fixed with this patch. We have tested all > combinations for x in [+1.fffdfp-1, +1.00020p+0] and y in > [-1.000007p+27, -1.000002p+27] and [1.000002p+27,1.000007p+27]. > --- > newlib/libm/math/ef_pow.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/newlib/libm/math/ef_pow.c b/newlib/libm/math/ef_pow.c > index e3579f071..07b225f8c 100644 > --- a/newlib/libm/math/ef_pow.c > +++ b/newlib/libm/math/ef_pow.c > @@ -138,7 +138,7 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 > tail*/ > /* |y| is huge */ > if(iy>0x4d000000) { /* if |y| > 2**27 */ > /* over/underflow if x is not close to one */ > - if(ix<0x3f7ffff8) return (hy<0)? > __math_oflowf(0):__math_uflowf(0); > + if(ix<0x3f7ffff4) return (hy<0)? > __math_oflowf(0):__math_uflowf(0); > if(ix>0x3f800007) return (hy>0)? > __math_oflowf(0):__math_uflowf(0); > /* now |1-x| is tiny <= 2**-20, suffice to compute > log(x) by x-x^2/2+x^3/3-x^4/4 */ > -- > 2.26.1.windows.1 > > >