random numbers !

bom brill bombrill_gmp@yahoo.fr
Wed, 18 Dec 2002 15:40:02 +0100 (CET)


--0-196047501-1040222402=:89230
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


I really have a problem with the mpz_urandomb() function. Perhaps I don t understand, but, for me, if I have that code : 

#include <gmp.h>
int main (int argc, char **argv)
{
  gmp_randstate_t state;
  mpz_t nbre1, nbre2;


  /* Initialisation  */
  mpz_init (nbre1);
  mpz_init (nbre2);
  gmp_randinit_default (state);


  /* on genere deux nbres de 10 bits */
  mpz_urandomb (nbre1, state, 10); 

  mpz_urandomb (nbre2, state, 10); 

  gmp_printf ("nbre1 : %Zd \n nbre2 : %Zd \n", nbre1, nbre2);

  gmp_randclear (state);
  mpz_clear (nbre1);
  mpz_clear (nbre2);

  return 0;
}


So, I expect, that each time, I'll run the programm, I'll get some new numbers.. because they are chosen randomly.. but it's not the case, and I always get the same..

Would you please help me ?? =))

 

Thanx anyway.. and sorry about my english ! ... I'm french !

 

jeremie



---------------------------------
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Testez le nouveau Yahoo! Mail
--0-196047501-1040222402=:89230
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<P>I really have a problem with the mpz_urandomb() function. Perhaps I don t understand, but, for me, if I have that code : </P>
<P>#include &lt;gmp.h&gt;<BR>int main (int argc, char **argv)<BR>{<BR>&nbsp; gmp_randstate_t state;<BR>&nbsp; mpz_t&nbsp;nbre1, nbre2;</P>
<P><BR>&nbsp; /* Initialisation&nbsp; */<BR>&nbsp; mpz_init (nbre1);<BR>&nbsp; mpz_init (nbre2);<BR>&nbsp; gmp_randinit_default (state);<BR></P>
<P>&nbsp; /* on genere deux&nbsp;nbres de 10 bits */<BR>&nbsp; mpz_urandomb (nbre1, state, 10); </P>
<P>&nbsp; mpz_urandomb (nbre2, state, 10);&nbsp;</P>
<P>&nbsp; gmp_printf ("nbre1 : %Zd&nbsp;\n nbre2 :&nbsp;%Zd \n", nbre1, nbre2);<BR><BR>&nbsp; gmp_randclear (state);<BR>&nbsp; mpz_clear (nbre1);<BR>&nbsp; mpz_clear (nbre2);<BR><BR>&nbsp; return 0;<BR>}<BR></P>
<P>So, I expect, that each time, I'll run the programm, I'll get some new numbers.. because they are chosen randomly.. but it's not the case, and I always get the same..</P>
<P>Would you please help me ?? =))</P>
<P>&nbsp;</P>
<P>Thanx anyway.. and sorry about my english ! ... I'm french !</P>
<P>&nbsp;</P>
<P>jeremie</P><p><br><hr size=1>Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !<br>
<a href=http://fr.mail.yahoo.com>Testez le nouveau Yahoo! Mail</a>
--0-196047501-1040222402=:89230--