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

fabioromano1 duke at openjdk.org
Thu Oct 2 10:14:50 UTC 2025


On Mon, 29 Sep 2025 16:12:20 GMT, fabioromano1 <duke at openjdk.org> wrote:

>> A formula to lower the overestimate for the precision of an exact quotient, without introducing too expensive operations of division on numerator and denominator.
>
> 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.

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

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


More information about the core-libs-dev mailing list