RFR: 8334755: Asymptotically faster implementation of square root algorithm [v28]
fabioromano1
duke at openjdk.org
Wed Jul 17 15:20:15 UTC 2024
On Wed, 17 Jul 2024 15:11:36 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> Also, this avoids a test
>>
>> if (Long.compareUnsigned(x, s * s - 1) <= 0) { // benign over- and underflows
>> s--;
>> }
>
> Sorry, disregard the above as it doesn't work for x = 0.
> Also, this avoids a test
>
> ```
> if (Long.compareUnsigned(x, s * s - 1) <= 0) { // benign over- and underflows
> s--;
> }
> ```
Yes, but... if `s == 0`, then `x == 0`, so `Long.compareUnsigned(x, s * s - 1) <= 0` and `s` is decremented... incorrectly.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/19710#discussion_r1681241965
More information about the core-libs-dev
mailing list