RFR: 8077587: BigInteger Roots [v18]

Raffaello Giulietti rgiulietti at openjdk.org
Fri Jul 11 12:41:43 UTC 2025


On Fri, 6 Jun 2025 08:08:09 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:
> 
>   Update "since" version

Sure, the initial value computed in the current commit of the PR is better, but I wonder if this makes any difference in practice, precisely because the Newton-Raphson method is so efficient anyway (but only measurements might tell).

On the other hand, the code contains about 80 lines just to find the initial estimate. To ensure that the code is readable and maintainable, it either needs to be documented better, possibly with math, or simplified so that the correctness becomes obvious even without comments.
Performance is not the only dimension we care about in the JDK. Readability and maintainability are even more important in the long term.

In any case, some comprehensive tests need to be added as well.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/24898#issuecomment-3062181616


More information about the core-libs-dev mailing list