RFR: 8356709: Avoid redundant String formatting in BigDecimal.valueOf(double) [v2]
Johannes Graham
duke at openjdk.org
Wed May 14 13:35:54 UTC 2025
On Wed, 14 May 2025 09:55:35 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> Johannes Graham has updated the pull request incrementally with one additional commit since the last revision:
>>
>> fix code tag in javadoc
>
> src/java.base/share/classes/java/math/BigDecimal.java line 1408:
>
>> 1406: }
>> 1407:
>> 1408: return valueOf(s, fmt.getScale(), fmt.getPrecision());
>
> I'd prefer to have a `getExp()` rather than `getScale()` in `FormattedFPDecimal`.
I was looking for a way clearly distinguish it from getExponentRounded. Will go with getExp, since it makes more sense in the scope of that class.
> test/jdk/java/math/BigDecimal/ValueOfDouble.java line 41:
>
>> 39:
>> 40: public class ValueOfDouble {
>> 41: private static final String DIGITS = "1234567899123456789"; // Enough digits to fill a long
>
> Suggestion:
>
> private static final String DIGITS = "1234567000003456789"; // Enough digits to fill a long
What is the significance of the positioning of the zeros? I wasn't really attaching any significance to the digit values other than making it easy to count how many there were.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25173#discussion_r2088959379
PR Review Comment: https://git.openjdk.org/jdk/pull/25173#discussion_r2088963691
More information about the core-libs-dev
mailing list