> 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 .

Actually, this appears to be a MoarVM specific issue:

$ ./perl6 -e 'use nqp; say "$_: {nqp::rand_I(2**$_,Int).base(2)}" for 58 .. 65'
58: 100100000001000010110110001000100000101010110001100111101
59: 11110010110000101100000101001101011110011011001011000110110
60: 1111001100010111000110101010101100001101100100011011100001
61: 11101111011010011101111000101010100101101010011010010000100
62: 11101100100111100101000000100101010010000110011011001111111011
63: 1011110010011000010110101111110100110001000100010011101000111
64: 110111111011110110110000101011110111100111100110101110101100011
65: 10101010010101100111111000001100111100110001001010001101000011

$ ./perl6 -e 'use nqp; say "$_: {nqp::rand_I(2**$_,Int).base(2)}" for 120 .. 
130'
120: 
101100000000100000100100110101010001010010101000010011011001000100110101111001010110001111110111100101011110110010001101
121: 
1111011110001010100110101000110110001001001100100101111101001101100010101110000111111110011000011000010100011000100110011
122: 
11101011010101110110110111011000101111100111011000111000001001101000111001010101011000010110110101101111100011001111000010
123: 
11101101010011111001110101101100110011000110100110011110011001011101111011111001010110111111111111110011010100011110001001
124: 
1101100101110101010100001011100101001111111100000011101011101000110100010111001001111101110001100101110001101000010011100010
125: 
10011000110001001101001001000000011101101000111101111110100111001001000101100111100001111001101001001000110001101111011001011
126: 
110100010001010011010100010000000111011100101011011001101010011100000001100111110000111110100101100000111100010110111010011
127: 
10010000010011000101010000000110101101110000111101111011001111000111011000010110111100100110000110001101001110000101001010010
128: 
11110010000001100110010000101111111000101101111000011001101001100001110010110101110101101010101110100011010110001001000000111000
129: 
100001010110011010110110001110011000000100011110111011010110100000011110000001011100100000110110111101010011111001000001111001
130: 
1101111101010101110001010000000000101100010100110100110000110011101100110111100010111111111111111011110011001010100111100101011000

Reply via email to