GMP random number generation.

Mikhail Gorbachev gorbachevma at gmail.com
Thu Mar 20 18:48:55 CET 2008


Hi.
I'm using GMP libriary to generate random numbers. I wrote this code
//------------------------------------------------------------------------------------
//...
    mpz_t rand_Num;
    gmp_randstate_t r_state;
    mpz_init2(rand_Num,32);
    gmp_randinit_default (r_state);
    mpz_urandomb(rand_Num,r_state,14);
    /* ...using generated random number...*/
    gmp_randclear(r_state);
//...  
//-------------------------------------------------------------------------------------

However, I cannot get the random number. For each run of the program the 
result of this code is always rand_Num = 10356. When I change 14 to some 
other number, the value of rand_Num changes but always remains the same 
for the same number.

I'm using the latest version of GMP libriary (4.2.2)

Is there a bug here or I just do something wrong?

Please feel free to respond me any time.
Thank you very much.
Mikhail Gorbachev.



More information about the gmp-bugs mailing list