RFR: 8077587: BigInteger Roots [v19]
Andrew Haley
aph at openjdk.org
Mon Apr 21 08:38:41 UTC 2025
On Sun, 20 Apr 2025 16:07:56 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 incrementally with one additional commit since the last revision:
>
> Code simplification
src/java.base/share/classes/java/math/MutableBigInteger.java line 2002:
> 2000: // Don't use conditional-or to ensure to do both divisions
> 2001: if (rToN.divideOneWord(n, q1) != 0
> 2002: | !q1.divide(new MutableBigInteger(rToN1.mag), delta).isZero())
Suggestion:
// Don't use conditional-or to ensure to do both divisions [because ...]
if ((rToN.divideOneWord(n, q1) != 0)
| (!q1.divide(new MutableBigInteger(rToN1.mag), delta).isZero()))
... add parens for clarity.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24690#discussion_r2052135457
More information about the core-libs-dev
mailing list