RFR: 8356891: Some code simplifications in BigInteger [v22]
fabioromano1
duke at openjdk.org
Tue May 27 17:17:00 UTC 2025
On Tue, 27 May 2025 15:26:42 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Correct typo in comment
>
> 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?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25166#discussion_r2109745054
More information about the core-libs-dev
mailing list