> On 07 Oct 2016, at 21:28, Patrick R. Michaud <pmich...@pobox.com> wrote:
> 
> On Fri, Oct 07, 2016 at 12:18:43PM -0700, Aaron Sherman wrote:
>> [15:12] <harmil_wk> m: say ((2**80) ..^ (2**81)).pick.base(2)
>> [15:12] <+camelia> rakudo-moar 605f27:
>> OUTPUT«100011101100100110010000000000000000000000000000000000010101111110101101010011001␤»
>> 
>> The middle part is always a large number of zeros, but it's my
>> understanding that it should be a more uniform and continuous range of
>> results.
> 
> Awesome catch!  The current implementation of Range.pick() is based on
> Range.roll(), which uses nqp::rand_I() to choose a random value from
> an integer range.
> 
> I'm guessing nqp::rand_I() is returning a 32-bit number, and so Range.pick/
> Range.roll are actually only returning values from 2**80 to 2**80+2**32-1 .

$ 6 'use nqp; say "$_: {nqp::rand_I(2**$_,Int).base(2)}" for 58 .. 65'
58: 1111001001001110101010001110011
59: 1001111001110100011111001011100
60: 11001111001100000101100000011
61: 10110000111000000101110101010
62: 1000000000000000000000000000000111100110101101101110111001101
63: 101000000000000000000000000000000001010101010110011001001111000
64: 1001000000000000000000000000000000101100110111100001110010111100
65: 10100000000000000000000000000000001101111110111111010001100001100

$ 6 'use nqp; say "$_: {nqp::rand_I(2**$_,Int).base(2)}" for 120 .. 130'
120: 
1011010110010100011000000000010000000000000000000000000000000010000000101100000000111011111
121: 
1101110011110100000000010011101000000000000000000000000000000001011101111100111110000010101
122: 
11000000000000000000000000000000001011101110000000000100001110000000000000000000000000000001011101010011010100010000100100
123: 
101000000000000000000000000000001111100100000101100100000010100000000000000000000000000000001101110000111011101100011101000
124: 
1000110000101010010001010110101000000000000000000000000000000010101100110011011110100000101
125: 
1111000000000000000000000000000000101001001101011110000111111000000000000000000000000000000000010000100001100111010111101011
126: 
100001000000000000000000000000000001010000101011010110011100110000000000000000000000000000000000101000010100011010100110110001
127: 
1101111000000000000000000000000000001010111001110011101110110000000000000000000000000000000000000010111111111010010101100111101
128: 
100100000000000000000000000000000001001001011000011110111101111011000000000000000000000000000000111100101100011001100111100000
129: 
111111100000000000000000000000000000001110010111010100011101000100111000000000000000000000000000001101111100100000001000101100001
130: 
10111001000000000000000000000000000001111101011011110000101011100001000000000000000000000000000000000101001100110111101000011101

Feels slightly more complicated than that.  But there’s definitely some 
32bitness involved.


Liz

Reply via email to