On Sun, 26 Nov 2023 16:52:40 GMT, fabioromano1 <d...@openjdk.org> wrote:

> A faster and simpler way to generate random BigIntegers, avoiding eventually 
> trimming of leading zeros in magnitude array.

src/java.base/share/classes/java/math/BigInteger.java line 732:

> 730:      */
> 731:     public BigInteger(int numBits, Random rnd) {
> 732:         // randomBits() returns a zero length array if len == 0

Should this comment say "if numBits == 0"?

src/java.base/share/classes/java/math/BigInteger.java line 754:

> 752:         // numInts >= 1, since numBits > 0
> 753: 
> 754:         int firstInt = rnd.nextInt() & (-1 >>> -numBits); // Mask out 
> any excess bits

Instead of `numBits`, shouldn't this use something like `excessBits` similar to 
line 760 in the old version?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16817#discussion_r1406843451
PR Review Comment: https://git.openjdk.org/jdk/pull/16817#discussion_r1406847756

Reply via email to