RFR: 8077587: BigInteger Roots [v78]
Raffaello Giulietti
rgiulietti at openjdk.org
Wed Sep 3 09:28:51 UTC 2025
On Fri, 29 Aug 2025 19:00:23 GMT, fabioromano1 <duke at openjdk.org> wrote:
>> This PR implements nth root computation for BigIntegers using Newton method.
>
> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>
> Revision changes
I think the PR is in a good state.
src/java.base/share/classes/java/math/MutableBigInteger.java line 2040:
> 2038: } else {
> 2039: // Discard wrong integer bits from the initial estimate
> 2040: // The radicand has Math.getExponent(rad)+1 integer bits, but only
Suggestion:
// The reduced radicand rad has Math.getExponent(rad)+1 integer bits, but only
src/java.base/share/classes/java/math/MutableBigInteger.java line 2059:
> 2057: /* The Newton's recurrence roughly duplicates the correct bits at each iteration.
> 2058: * Instead of shifting the approximate root into the original range right now,
> 2059: * we only duplicate its bit length and then refine it with Newton's recurrence,
Suggestion:
/* The Newton's recurrence roughly doubles the correct bits at each iteration.
* Instead of shifting the approximate root into the original range right now,
* we only double its bit length and then refine it with Newton's recurrence,
src/java.base/share/classes/java/math/MutableBigInteger.java line 2060:
> 2058: * Instead of shifting the approximate root into the original range right now,
> 2059: * we only duplicate its bit length and then refine it with Newton's recurrence,
> 2060: * using a congruent shifted radicand, in order to avoid computing and
Maybe clarify what "congruent" means here
-------------
PR Review: https://git.openjdk.org/jdk/pull/24898#pullrequestreview-3179775832
PR Review Comment: https://git.openjdk.org/jdk/pull/24898#discussion_r2318360217
PR Review Comment: https://git.openjdk.org/jdk/pull/24898#discussion_r2318360557
PR Review Comment: https://git.openjdk.org/jdk/pull/24898#discussion_r2318360386
More information about the core-libs-dev
mailing list