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

fabioromano1 duke at openjdk.org
Fri Jul 12 14:25:54 UTC 2024


On Fri, 12 Jul 2024 13:08:37 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Added comment on normalization in MutableBigInteger.sqrtRemZimmermann()
>
> src/java.base/share/classes/java/math/MutableBigInteger.java line 2054:
> 
>> 2052: 
>> 2053:                 rem.add(ONE);
>> 2054:                 rem.subtract(twiceSqrt);
> 
> Shouldn't these be `rem + twiceSqrt - 1`?

No, because `rem` is unsigned, so to perform the correct computation you must first add the absolute value of the addends with the same sign, and the subtract the absolute value of those with opposite sign.

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

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


More information about the core-libs-dev mailing list