RFR: 8356709: Avoid redundant String formatting in BigDecimal.valueOf(double) [v2]
Raffaello Giulietti
rgiulietti at openjdk.org
Wed May 14 14:39:38 UTC 2025
On Wed, 14 May 2025 13:33:32 GMT, Johannes Graham <duke at openjdk.org> wrote:
>> 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. The zeros would combine with the exponent to miss some values for precision. I had also experimented with using 100...001, but it made for messier code. Going with your suggestion to start with.
The test copies a prefix, so we want to make sure that trailing zeros are processed correctly.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25173#discussion_r2089099807
More information about the core-libs-dev
mailing list