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

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


On Sat, 26 Apr 2025 19:16:14 GMT, Chen Liang <liach 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))

Generally, use privitive integers arithmentic is faster than using BigInteger arithmentic. Anyway, `nthRoot()` depends on `unsignedLongPow()`, so it cannot be avoided without losing performance in nth root computing.

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

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


More information about the core-libs-dev mailing list