RFR: 8077587: BigInteger Roots [v18]
fabioromano1
duke at openjdk.org
Mon Apr 21 08:06:52 UTC 2025
On Sun, 20 Apr 2025 05:12:19 GMT, Chen Liang <liach at openjdk.org> wrote:
>> 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/d7448f7e...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()`?
It should be, because `multiply(BigInteger)` checks the size of the argument in order to call `square()` when it is more convenient.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24690#discussion_r2052102817
More information about the core-libs-dev
mailing list