Subject: bug#32605: 26.1; (random) never returns negative

From: Andy Moreton <[email-masked]>
Date: Wed, 05 Sep 2018 14:20:48 +0100

On Tue 04 Sep 2018, Noam Postavsky wrote:

> retitle 32605 [w64] (random) never returns negative
> tags 32605 + confirmed
> quit
>
> Stephen Berman <[email-masked]> writes:
>
>> On Sat, 01 Sep 2018 18:18:01 +0100 Francis Wright <[email-masked]> wrote:
>>> Therefore, it should return a negative integer
>>> half the time, but I have never yet seen it return a negative value.
>
>>> In GNU Emacs 26.1 (build 1, x86_64-w64-mingw32)
>
>> Prompted by this report, I just ran `M-: (random)' twice, with these
>> results:
>>
>> 1407814790132564328 (#o116114401367331100550, #x13899017bb648168)
>> -5902216973509885 (#o-247600437205762375, #x-14f808fa17e4fd)
>>
>> This was on a build from current master under GNU/Linux
>
> This bug seems specific to 64 bit Windows builds.

ON 64bit Windows, sysdep.c sets RAND_BITS to 31, but random (in w32.c)
only provides 30 bits. It looks like the mixing in get_random does not
result in the top fixnum bit being set.

    AndyM