RFR: 8334755: Asymptotically faster implementation of square root algorithm [v47]

Raffaello Giulietti rgiulietti at openjdk.org
Mon Jul 29 17:02:44 UTC 2024


On Mon, 29 Jul 2024 16:49:04 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   If the input is a square, then s0 == 0, so testing for non-zero remainder is redundant
>
> src/java.base/share/classes/java/math/MutableBigInteger.java line 1891:
> 
>> 1889:         int shift = Integer.numberOfLeadingZeros(x.value[x.offset]) & ~1; // shift must be even
>> 1890:         if ((x.intLen & 1) != 0)
>> 1891:             shift += 32; // x.intLen must be even
> 
> Suggestion:
> 
>         int shift = (Integer.numberOfLeadingZeros(x.value[x.offset]) & ~1) + ((x.intLen & 1) << 32);

Sorry, not `<<` but `*`

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19710#discussion_r1695564832


More information about the core-libs-dev mailing list