Date: Thu, 26 Mar 1998 19:27:30 +0100 From: Hans-Bernhard Broeker Message-Id: <199803261827.TAA14769@acp3bf.physik.rwth-aachen.de> To: a DOT hofkamp AT wtb DOT tue DOT nl Cc: djgpp AT delorie DOT com Subject: Re: real random numbers Newsgroups: comp.os.msdos.djgpp Organization: RWTH Aachen, III. physikalisches Institut B Precedence: bulk In article <6fe13v$55q AT tuegate DOT tue DOT nl> you wrote: > In article <35169C99 DOT 3B53 AT pobox DOT oleane DOT com>, > Francois Charton writes: > > generating random looking maps). If you want a "true" (non replicable) > > random series, you may want to use srand(time()) as a seed. > As some people already have pointed out, this only works when your > program runs at least for a single second. I find it hard to imagine a program that runs through in less than one second, but still has a real need for guaranteed different random seeds each run :-) Such a program might be better transformed into a centralized, long-running server process instead, using a single normal pseudo-random number sequence. > Does somebody know how to take care of getting a different value each > time you run a program, no matter how often in a single second you start > it ? That target is absolutely impossible to reach, I think. Reason: time() counts seconds (in DJGPP), and is 32 bits wide. The srandom argument is also a 32 bit number. If you want to start your program more than once per second, and insist on absolutely unique seeds per run, you'll run out of numbers before time() reaches its limit of usability (some time in the year 2037...). I.e. you can start that program more often than there are different, unique seeds. In the high energy physics experiment I'm in, we maintain an experiment-wide seed value for that very reason: each time a statistical simulation job is started, it requests a 'secure' seed from the central database, and the central value is increased automatically. All this just to avoid that two people start the same simulation job, using time() as the seed, in exactly the same second, and get the exact same results, by this coincidence. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.