On Tue, 27 May 2025 17:14:32 GMT, fabioromano1 <d...@openjdk.org> wrote:

>> src/java.base/share/classes/java/math/BigInteger.java line 4732:
>> 
>>> 4730:         /* Allocate output array.  If all non-sign ints are 0x00, we 
>>> must
>>> 4731:          * allocate space for one extra output int. */
>>> 4732:         for (i = a.length - 1; i >= keep && a[i] == 0; i--) // Skip 
>>> trailing zeros
>> 
>> I think there's no need to check for `i >= keep`.
>> Suggestion:
>> 
>>         for (i = a.length - 1; a[i] == 0; i--) // Skip trailing zeros
>
> @rgiulietti Because the method assumes that `a` represents a two's complement 
> negative integer, so there is at least a sign bit?

There's only one usage of `makePositive(int[])`, and only when `a[0] < 0`.
And then there's the method comment that assumes a negative 2's complement 
number in `a`.

But if you don't feel sure, I don't mind keeping the line as it is.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25166#discussion_r2109770395

Reply via email to