From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: Random implementation Date: Wed, 28 Jan 1998 01:15:39 -0800 Organization: Alcyone Systems Lines: 25 Message-ID: <34CEF73B.493E9C2D@alcyone.com> References: <6am4ri$dtk$2 AT herald DOT Mines DOT EDU> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Jean-Luc Romano wrote: > I could seed the function with time(NULL) like so: srand(time(NULL)); > but (I think) that seeds the generator based on the system seconds, > so one out of every 60 runs will produce the same random numbers. ANSI C does not put any restrictions whatsoever on the encoding of the the value returned by time. In many systems, it is the number of seconds since some reference date. DJGPP is one of these systems, and as such, the value returned by time will only repeat itself once every 2^32 seconds (srand takes an unsigned int, which in DJGPP is the same size as a time_t). 2^32 s = 4.30 Gs = 136 y. So it's hardly something to worry about. Calling srand(time(0)) is the conventional way to seed the random number generator. -- Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com Alcyone Systems / http://www.alcyone.com/max/ San Jose, California, United States / icbm://+37.20.07/-121.53.38 \ "Life may be / the product of imperfections." / (Marclo Gleiser)