From owner-svn-src-head@freebsd.org Thu Jul 19 15:04:11 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B4793103D6DF; Thu, 19 Jul 2018 15:04:11 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6680395232; Thu, 19 Jul 2018 15:04:11 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 472FE2AD11; Thu, 19 Jul 2018 15:04:11 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6JF4B9I080235; Thu, 19 Jul 2018 15:04:11 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6JF4AFD080232; Thu, 19 Jul 2018 15:04:10 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201807191504.w6JF4AFD080232@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Thu, 19 Jul 2018 15:04:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336488 - head/lib/msun/src X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/lib/msun/src X-SVN-Commit-Revision: 336488 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2018 15:04:11 -0000 Author: bde Date: Thu Jul 19 15:04:10 2018 New Revision: 336488 URL: https://svnweb.freebsd.org/changeset/base/336488 Log: Fix spurious and extra underflows and resulting inaccuracies for some cases with 1 huge component and 1 tiny (but nowhere near denormal) component. Rescale earlier so that a scale factor of 2 can be combined with a non- scale divisor of 2, so that the division doesn't shift out a bit. In the usual case where the scale factor is just 1, the division may shift out a bit, but then the underflow is not spurious and the inaccuracies are harder to fix. Modified: head/lib/msun/src/s_csqrt.c head/lib/msun/src/s_csqrtl.c Modified: head/lib/msun/src/s_csqrt.c ============================================================================== --- head/lib/msun/src/s_csqrt.c Thu Jul 19 14:41:46 2018 (r336487) +++ head/lib/msun/src/s_csqrt.c Thu Jul 19 15:04:10 2018 (r336488) @@ -99,15 +99,15 @@ csqrt(double complex z) /* Algorithm 312, CACM vol 10, Oct 1967. */ if (a >= 0) { t = sqrt((a + hypot(a, b)) * 0.5); - rx = t; - ry = b / (2 * t); + rx = scale * t; + ry = scale * b / (2 * t); } else { t = sqrt((-a + hypot(a, b)) * 0.5); - rx = fabs(b) / (2 * t); - ry = copysign(t, b); + rx = scale * fabs(b) / (2 * t); + ry = copysign(scale * t, b); } - return (CMPLX(rx * scale, ry * scale)); + return (CMPLX(rx, ry)); } #if LDBL_MANT_DIG == 53 Modified: head/lib/msun/src/s_csqrtl.c ============================================================================== --- head/lib/msun/src/s_csqrtl.c Thu Jul 19 14:41:46 2018 (r336487) +++ head/lib/msun/src/s_csqrtl.c Thu Jul 19 15:04:10 2018 (r336488) @@ -114,13 +114,13 @@ csqrtl(long double complex z) /* Algorithm 312, CACM vol 10, Oct 1967. */ if (a >= 0) { t = sqrtl((a + hypotl(a, b)) * 0.5); - rx = t; - ry = b / (2 * t); + rx = scale * t; + ry = scale * b / (2 * t); } else { t = sqrtl((-a + hypotl(a, b)) * 0.5); - rx = fabsl(b) / (2 * t); - ry = copysignl(t, b); + rx = scale * fabsl(b) / (2 * t); + ry = copysignl(scale * t, b); } - return (CMPLXL(rx * scale, ry * scale)); + return (CMPLXL(rx, ry)); }