On Fri, 12 Jul 2024 14:22:33 GMT, fabioromano1 <d...@openjdk.org> wrote:

>> 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 then 
> subtract the absolute value of those with opposite sign.

Ah right, this is the semantics of `MBI.subtract`.

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

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

Reply via email to