RFR: 8356709: Avoid redundant String formatting in BigDecimal.valueOf(double)
Chen Liang
liach at openjdk.org
Mon May 12 14:43:10 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.
Thanks for this improvement! Looks great!
Sorry, didn't see your core-libs-dev mail. Created an issue for you at https://bugs.openjdk.org/browse/JDK-8356709
test/jdk/java/math/BigDecimal/ValueOfDouble.java line 14:
> 12:
> 13: public class ValueOfDouble {
> 14: private static final String DIGITS = "1234567899123456789"; // Enough digits to fill a long
Should we consider including 0 in this list?
This file needs a license header, and the jtreg directive should be `/*` instead of `/**` and usually placed before imports, and usually we include a `@bug` tag (once there is an issue ID) and a `@summary` tag.
-------------
PR Review: https://git.openjdk.org/jdk/pull/25173#pullrequestreview-2831469156
PR Comment: https://git.openjdk.org/jdk/pull/25173#issuecomment-2870517444
PR Review Comment: https://git.openjdk.org/jdk/pull/25173#discussion_r2083592761
More information about the core-libs-dev
mailing list