On Wed, 9 Oct 2024 14:28:53 GMT, fabioromano1 <d...@openjdk.org> wrote:

>> Seems like `BigInteger`s division either takes care of removing common 
>> powers of 2 in the dividend and divisor (Knuth division), or removing them 
>> has no practical benefit (Burnikel-Ziegler).
>> 
>> Thus, I'm wondering if using powers of 10 rather than powers of 5 in the 
>> stripping logic could simplify the code while retaining comparable 
>> performance.
>> 
>> The powers of 10 are already indirectly kept in the class by method 
>> `bigTenToThe()` (although they affect resident memory footprint). However, 
>> since that method is there to stay and used in other places as well, it 
>> might be worthwhile to profit from it.
>
> @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.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1793763450

Reply via email to