Re: pass time(0) to srand() when generating random numbers.

From: Andreas Kahari (ak+usenet_at_freeshell.org)
Date: 10/31/03


Date: Fri, 31 Oct 2003 09:02:42 +0000 (UTC)

In article <d93e2a33.0310310045.575d3fb9@posting.google.com>, Intaek LIM wrote:
[cut]
> // seed is the return value for time(0)
> // i wrote it by my hand. :-(
> int seed = 1067589554;
> srand(seed);

The time() function returns a value that represents the current
time. Seeding the pseudo random generator with time(0) will
ensures that you get a different pseudo random list of numbers
each time you run the program.

Hard coding the seed ("1067589554" in your code) ensures that
you get the *same* pseudo random list of numbers each time you
run your program.

-- 
Andreas Kähäri


Relevant Pages

  • Re: random numbers and statistics
    ... >statistics on the results of nuemrical calculations that were done ... >I'm wondering if the pseudo random generator will show false ...
    (sci.math)
  • Re: How to do magic with infinity
    ... Frank Piron wrote: ... > there are two origins possible ... > It is a pseudo random generator and thus an ordinary number ... It IS a pseudo random number generator. ...
    (sci.logic)
  • Re: How to do magic with infinity
    ... Frank Piron wrote: ... > there are two origins possible ... > It is a pseudo random generator and thus an ordinary number ... It IS a pseudo random number generator. ...
    (sci.math)