RFR: 4837946: Faster multiplication and exponentiation of large integers [v35]

fabioromano1 duke at openjdk.org
Sat Apr 26 19:35:46 UTC 2025


On Sat, 26 Apr 2025 19:24:21 GMT, fabioromano1 <duke at openjdk.org> wrote:

> It seems your new `unsignedIntPow` already covers `base.mag.length == 1` case - your `unsignedLongPow` and `unsignedIntPow` are otherwise identical. Can we just remove this long shortcut and `unsignedLongPow` and use the newly established `unsignedIntPow`? That can also remove lots of redundant code and significantly reduce maintenance cost. (Unless BigInteger.multiply(long) is much cheaper than BigInteger.multiply(BigInteger))

An alternative solution is to simply throw away `unsignedIntPow()` and use always BigInteger arithmetic when the result could exceed a the `long` bits size.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24690#discussion_r2061559369


More information about the core-libs-dev mailing list