RFR: 8077587: BigInteger Roots [v18]
Chen Liang
liach at openjdk.org
Mon Apr 21 01:36:50 UTC 2025
On Sat, 19 Apr 2025 19:23:26 GMT, fabioromano1 <duke at openjdk.org> wrote:
>> This PR implements nth root computation for `BigInteger`s using Newton method and optimizes `BigInteger.pow(int)` method.
>> [Here is a proof of convergence of the recurrence used.](https://github.com/user-attachments/files/19785045/nth_root_newton_proof_integers.pdf)
>
> fabioromano1 has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 21 additional commits since the last revision:
>
> - Merge branch 'openjdk:master' into BigInteger-nth-root
> - Format code
> - Format code
> - An optimization
> - An optimization
> - Extend use cases of MutableBigInteger.valueOf(double)
> - BigIntegers nth root's initial estimate optimization
> - An optimization
> - Memory usage optimization
> - Correct left shift if shift is zero
> - ... and 11 more: https://git.openjdk.org/jdk/compare/966f9022...524f195e
src/java.base/share/classes/java/math/BigInteger.java line 2669:
> 2667: // Perform exponentiation using repeated squaring trick
> 2668: for (int expLen = Integer.SIZE - expZeros; expLen > 0; expLen--) {
> 2669: answer = answer.multiply(answer);
Is `answer.multiply(answer)` faster than `answer.square()`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24690#discussion_r2051636729
More information about the core-libs-dev
mailing list