New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.pick on large ranges gives unexpected results on Windows only #6059
Comments
From @mschaOn my self-compiled Linux build of Rakudo Star 2017.01: % perl6 -e 'say (-524288..^524288).pick(50)' This looks pretty normal. But on my Windows machine, using the 64-bit version of Rakudo Star % perl6 -e 'say (-524288..^524288).pick(50)' I.e., I consistently get numbers close to the bottom end of the range. |
From @nwc10OK, this is a bit of guessing, and I would like to think that I've guessed On Sun, Feb 05, 2017 at 03:21:12PM -0800, Michael Schaap wrote:
Windows. Random numbers. 3rdparty/libtommath/bn_mp_rand.c has: /* first place a random non-zero digit */ if ((res = mp_add_d (a, d, a)) != MP_OKAY) { while (--digits > 0) { if ((res = mp_add_d (a, ((mp_digit) abs (MP_GEN_RANDOM())), a)) != MP_OKAY) { 3rdparty/libtommath/tommath.h has: /* use arc4random on platforms that support it */ #define MP_DIGIT_BIT DIGIT_BIT and #ifdef MP_31BIT Which I think means that it's either using 28 or 31 bit "digits". IIRC rand() on Win32 only returns 15 bit values. If so, this third-party code is buggy. But if that's true, why on Earth has no-one else hit this before? Nicholas Clark |
The RT System itself - Status changed from 'new' to 'open' |
From @geekosaurOn Mon, Feb 6, 2017 at 3:31 PM, Nicholas Clark <nick@ccl4.org> wrote:
You'd be surprised. Verifying randomness is fairly tricky... and Perl 3 -- |
Migrated from rt.perl.org#130723 (status was 'open')
Searchable as RT130723$
The text was updated successfully, but these errors were encountered: