Karim BELABAS on Tue, 21 Oct 2003 16:43:47 +0200 (MEST)


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

Re: random(x) for x in [2^31, 2^32)


On Fri, 17 Oct 2003, Phil Carmody wrote:
> while(1,m=random(2^31);print(m))
> 4242106392
[...]
> all too high
>
>
> while(1,print(random(2^32-1)))
> 0
[...]
> all suspiciously low.
>
> 2.2.6 on x86.
>
> My alpha doesn't seem to have problems either there or at the
> 2^63..2^64-1 cutoff (assuming that 64-bits is a significant unit for an
> alpha), but it's running only 2.1.5, alas.

Diagnosed and fixed by Brian Gladman: there was a (unsigned / signed) long
confusion in mp_indep.c:randomi().

Fixed in CVS.

    Karim.
-- 
Karim Belabas                     Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425   Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud              http://www.math.u-psud.fr/~belabas/
F-91405 Orsay (France)            http://www.parigp-home.de/  [PARI/GP]