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

Joe Darcy darcy at openjdk.org
Mon Oct 27 19:53:08 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 1799:

> 1797:         if (this.signum() == 0) // 0/y
> 1798:             return zeroValueOf(preferredScale);
> 1799:         else {

The old algorithm has relatively few paths through it for different arguments.

Do the existing test cases provide adequate coverage of the new set of code paths?

test/jdk/java/math/BigDecimal/DivideTests.java line 28:

> 26:  * @bug 4851776 4907265 6177836 6876282 8066842 8367603
> 27:  * @summary Some tests for the divide methods.
> 28:  * @author Joseph D. Darcy

Please sync with master soon; this author tag has been been removed.

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

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


More information about the core-libs-dev mailing list