Hello, this appears to be a harmless cleanup that has no behavioral impact. 
Created https://bugs.openjdk.org/browse/JDK-8374202 for this.
Feel free to follow our guide at https://openjdk.org/guide/ to submit a PR on 
GitHub for this issue.

Regards,
Chen Liang
________________________________
From: core-libs-dev <[email protected]> on behalf of John Platts 
<[email protected]>
Sent: Sunday, December 21, 2025 6:02 PM
To: [email protected] <[email protected]>
Subject: Replace loop with Long.numberOfTrailingZeros in BigDecimal(double val, 
MathContext mc) constructor

The following loop in the java.math.BigDecimal(double val, MathContext mc) 
constructor is inefficient:
        while ((significand & 1) == 0) { // i.e., significand is even
            significand >>= 1;
            exponent++;
        }

Here is a more efficient alternative using Long.numberOfTrailingZeros:
        final int numOfTrailingZerosInSignificand =
            Long.numberOfTrailingZeros(significand);
        significand >>= numOfTrailingZerosInSignificand;
        exponent += numOfTrailingZerosInSignificand;

Reply via email to