8215441: Increase uniformity of the distribution of BigIntegers constructed by BigInteger(int, Random)
brian.burkhalter at oracle.com
Thu Dec 20 17:08:04 UTC 2018
Thanks for the comments. It looks like I got this completely wrong. For some reason I was thinking that the distribution of bit lengths should be uniform which is patently incorrect. Consider the example of a four bit integer. The possible values are
1111 1110 1101 1100 1011 1010 1001 1000
0111 0110 0101 0100
Half of the values have bit length 4, 25% have bit length 2, etc. Re-running my test code shows pretty much this sort of distribution of the bit lengths. It looks like the likelihood of bit lengths from the largest length downward is a geometric sequence with initial value 0.5 for the largest bit length and common ratio 0.5. So I concur with Adam that the current implementation looks correct. Therefore I think that  should be withdrawn and  closed as not an issue.
More information about the core-libs-dev