Re: question on rand()

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

 



The program I wrote uses 2*10^8 random numbers which are produced using rand. Is there a way to find if rand produces duplicates in my program? I found that RAND_MAX is equal to 2^31-1 in the machine I am using.

Anna

----- Original Message -----
From: Ian Lance Taylor <iant@xxxxxxxxxx>
Date: Saturday, August 6, 2011 10:01 pm
Subject: Re: question on rand()

> Anna Sidera <sidera.anna@xxxxxxxxx> writes:
> 
> >>From this, can I find out when the numbers start repeating? How 
> can I find it? I cannot find the period using
> >
> > man rand
> 
> This question really doesn't have anything to do with gcc.  gcc 
> does not
> provide a rand function.  The rand function will come from your C
> library, and gcc does not include a C library.
> 
> If you are using GNU glibc, which is probably the case if you are 
> usinga GNU/Linux system, then rand is not implemented as a linear
> congruential generator, and the period is quite long.  See the source
> code.
> 
> Ian
> 


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux