RFR: 4837946: Faster multiplication and exponentiation of large integers [v34]
Chen Liang
liach at openjdk.org
Sat Apr 26 17:10:47 UTC 2025
On Sat, 26 Apr 2025 16:44:26 GMT, fabioromano1 <duke at openjdk.org> wrote:
>> This PR optimizes `BigInteger.pow(int)` method. The primary enhancement in `pow()` is not concerned most on execution time, but rather in memory optimization, because the PR implementation does the "shift of the exponent" squaring the result rather than the base, so the base is not squared like in the current implementation, and this permits to save about half of the memory.
>
> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>
> Removed method used by nth-root
src/java.base/share/classes/java/math/BigInteger.java line 2707:
> 2705: // such that x^e fits into a double. If e <= 2, we won't use fp arithmetic.
> 2706: // This allows to use fp arithmetic where possible.
> 2707: final int maxExp = Math.max(2, Double.PRECISION / bitLengthForInt(x));
We should link this 2 to the logic to xToExpAdj below - with comments on both sites.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24690#discussion_r2061492878
More information about the core-libs-dev
mailing list