On Mon, 27 Nov 2023 22:34:12 GMT, Brian Burkhalter <b...@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 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? It's equivalent. If you watch the implementations of other methods in the class where a mask out is made, this method is often used. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/16817#discussion_r1406865830