RFR: 8370013: Refactor Double.toHexString to eliminate regex and StringBuilder [v2]

Raffaello Giulietti rgiulietti at openjdk.org
Mon Oct 20 14:18:11 UTC 2025


On Mon, 20 Oct 2025 08:59:16 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   from @jddarcy
>
> src/java.base/share/classes/java/lang/Double.java line 712:
> 
>> 710:             return Double.toString(d);
>> 711:         else {
>> 712:             boolean negative = Math.copySign(1.0, d) == -1.0;
> 
> Suggestion:
> 
>             boolean negative = Math.copySign(1.0, d) < 0.0;

Suggestion:

            boolean negative = Double.doubleToLongBits(d) < 0;

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27811#discussion_r2445143385


More information about the core-libs-dev mailing list