RFR: 8367603: Optimize exact division in BigDecimal [v22]

Raffaello Giulietti rgiulietti at openjdk.org
Thu Oct 2 10:47:11 UTC 2025


On Thu, 2 Oct 2025 10:12:01 GMT, fabioromano1 <duke at openjdk.org> wrote:

>> fabioromano1 has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Simplification
>>  - Update DivideTests.java
>
> src/java.base/share/classes/java/math/BigDecimal.java line 4294:
> 
>> 4292:         }
>> 4293: 
>> 4294:         return BigInteger.TEN.pow(n);
> 
> Suggestion:
> 
>         return fiveTo(n).shiftLeft(n);
> 
> @rgiulietti  I had thought about replacing the instruction on L. 4294 with the one above, but the `AddTests.java` of `BigDecimal` tests raises a timeout error.

I have not clue why this would cause a timeout, but I didn't investigate deeper.

But how would this change help with _this_ PR?
Performance is already much better, and as long as the results are correct, I would postpone other performance enhancements to a followup PR.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27271#discussion_r2398274810


More information about the core-libs-dev mailing list