On Wed, 9 Oct 2024 15:46:37 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> wrote:
>> @rgiulietti >> - About powers of two, there is a difference here: all powers of two are >> removed, not only the common, to use numbers as small as possible, and the >> powers are removed all in once, while if not they were removed at each >> division and also in the divisor, which is a power of 10, slowing the time >> of every iteration. >> - About `bigTenToThe()`: its shortcoming is that the powers are calculated >> multiplying by 10 each time, rather than using repeated squares trick, until >> the cache is completely filled. >> >> These are the main reasons why I decided not to use `bigTenToThe()`. > > Oh right, `expandBigIntegerTenPowers()` indeed computes and stores a lot of > values. > > I'm thinking of opening an issue to rewrite it to just keep the values that > are actually computed as intermediate results of a repeated squaring > implementation. @rgiulietti BTW of opening new issues, I've found that there are some optimizations and code simplifications that can be done in `BigInteger`'s bit operations that uses lowest non-zero word search, like `shiftRight()`, `getLowestSetBit()`, `bitLength()` and `bitCount()`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1793787866