guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Random numbers broken on 64-bit platforms


From: Andreas Rottmann
Subject: Re: Random numbers broken on 64-bit platforms
Date: Sun, 18 Jul 2010 01:18:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Andreas Rottmann <address@hidden> writes:

> Hi!
>
> While implementing SRFI-27, I noticed that Guile's RNG is quite broken
> on 64-bit platforms (where unsigned long is 64 bit). This has two
> consequences:
>
> - Crashes for some numbers between 2^32 and 2^63; for example try this:
>
>   (random (expt 2 46))
>
> - Bignum random numbers will be seriously distorted in their
>   distribution, since scm_c_random() only returns 32 random bits, and
>   that function is used by scm_c_random_bignum(), which expects it to
>   return a `unsigned long' worth of random bits, AFAICT.
>
> I believe the attached patch fixes this issue.
>
I should add that this affects both 1.8.7 and current git.

Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.yi.org/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]