RFR: 8356709: Avoid redundant String formatting in BigDecimal.valueOf(double)

Joe Darcy darcy at openjdk.org
Tue May 13 04:07:52 UTC 2025


On Sun, 11 May 2025 16:22:11 GMT, Johannes Graham <duke at openjdk.org> wrote:

> Optimize `BigDecimal.valueOf(double)` by using `FormattedFPDecimal` instead of converting to decimal string and then parsing it. This results in an approximate 6x improvement for me.

src/java.base/share/classes/jdk/internal/math/FormattedFPDecimal.java line 141:

> 139:     /**
> 140:      * Value <code>scale</code>, such that
> 141:      * <code> value = (f × 10<sup>-scale</sup>)</code>

Raw javadoc nit: wherever possible, please use `{@code foo}` rather than `<code>foo</code>`. I find the former much easier to read and it is fewer characters too.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25173#discussion_r2085880551


More information about the core-libs-dev mailing list