Reduce memory consumption of BigInteger.pow() by adopting a better computation strategy.
By iterating the exponent bits from left to right (from most to least significant), only the current running result needs to be squared and multiplied, while the base is untouched.
The memory savings are substantial, up to 45% w.r.t. the current implementation.
By iterating the exponent bits from left to right (from most to least significant), only the current running result needs to be squared and multiplied, while the base is untouched.
The memory savings are substantial, up to 45% w.r.t. the current implementation.
- relates to
-
JDK-4837946 Faster multiplication and exponentiation of large integers
-
- Closed
-
- links to
-
Commit(master) openjdk/jdk/1c5eb370
-
Review(master) openjdk/jdk/24690