RFR: 8077587: BigInteger Roots [v74]
Joe Darcy
darcy at openjdk.org
Fri Aug 29 05:02:56 UTC 2025
On Thu, 28 Aug 2025 15:08:04 GMT, fabioromano1 <duke at openjdk.org> wrote:
>> This PR implements nth root computation for BigIntegers using Newton method.
>
> fabioromano1 has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 120 commits:
>
> - Merge branch 'openjdk:master' into nth-root-branch
> - Ensure root's overestimate in for loop
> - Refine comment
> - Refine comment
> - Refine comments
> - Refine comments
> - An optimization
> - Code simplification
> - Removed dead code
> - Merge branch 'openjdk:master' into nth-root-branch
> - ... and 110 more: https://git.openjdk.org/jdk/compare/993babb3...d5ff3a65
src/java.base/share/classes/java/math/BigInteger.java line 2747:
> 2745: /**
> 2746: * Returns the integer {@code n}th root of this BigInteger. The integer
> 2747: * {@code n}th root {@code r} of the corresponding mathematical integer {@code x}
Formatting nit: in cases like this I would use `{@code n}<sup>th</sup>`.
src/java.base/share/classes/java/math/BigInteger.java line 2764:
> 2762: * the magnitude of the real {@code n}th root if the latter is not representable
> 2763: * as an integral value.
> 2764: *
I think it would be helpful to the reader to have an `@apiNote` that explicitly said "nthRoot(2) is semantically equivalent to sqrt" even if that fact is implied by the other text.
The addition of such an `@apiNote` would not require additional CSR review.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24898#discussion_r2309142246
PR Review Comment: https://git.openjdk.org/jdk/pull/24898#discussion_r2309141035
More information about the core-libs-dev
mailing list