From 5ee5a5919298a037f859e0f14bc058eb29710eb3 Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Thu, 11 Jan 2018 17:14:16 -0800 Subject: Fix another square root performance bug Bug: 71686706 This one actually fixes the above issue in AOSP. Without this, sqrt() tended to force evaluation of the argument to twice the the requested precision, which clearly didn't scale. For some reason, that didn't seem to be reproducible for all calculator versions. Test: Calculator tests + CR tests Change-Id: I2cc0053f5e27d5d0364c707fe580aa246bbf99d0 --- src/com/hp/creals/CR.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/hp/creals/CR.java b/src/com/hp/creals/CR.java index 9e10b51..e7cd26a 100644 --- a/src/com/hp/creals/CR.java +++ b/src/com/hp/creals/CR.java @@ -1502,7 +1502,7 @@ class sqrt_CR extends CR { final int fp_op_prec = 60; protected BigInteger approximate(int p) { int max_op_prec_needed = 2*p - 1; - int msd = op.msd(max_op_prec_needed); + int msd = op.iter_msd(max_op_prec_needed); if (msd <= max_op_prec_needed) return big0; int result_msd = msd/2; // +- 1 int result_digits = result_msd - p; // +- 2 -- cgit v1.2.3