RFR: 8341470: BigDecimal.stripTrailingZeros() optimization [v35]

fabioromano1 duke at openjdk.org
Fri Oct 11 18:29:14 UTC 2024


On Fri, 11 Oct 2024 17:40:21 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Refining mathematical definition of remainingZeros
>
> src/java.base/share/classes/java/math/BigDecimal.java line 5274:
> 
>> 5272:         remainingZeros = Math.min(remainingZeros, maxPowsOf5);
>> 5273: 
>> 5274:         BigInteger[] qr; // quotient-remainder pair
> 
> The algorithm is clever, but it took me some time to "reverse-engineer" to understand how it works.
> 
> If this is described somewhere in the literature, please add a reference.
> Otherwise, it needs an explanation in form of comments.

I don't know any description of the repeated squares technique applied for stripping zeros in the literature...

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

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


More information about the core-libs-dev mailing list