Is continuously seeding a random number generator performance intensive?

Andrea Fontana nospam at example.com
Fri Jan 3 05:39:40 PST 2014


On Friday, 3 January 2014 at 01:01:21 UTC, Frustrated wrote:
> On Thursday, 2 January 2014 at 20:38:10 UTC, Jeroen Bollen 
> wrote:
> [...]
> e.g.,
>
> seed(k);
> for(i = 1..10)
> print(rnd(i));
>
> and
>
> for(i = 1..10)
> {
> seed(time);
> print(rnd(i));
> }
>
> will both produce random sequences of numbers(and random 
> sequences of numbers are "identically random".
> [...]

The second example is error-prone. If "time" var doesn't change 
between cycle, it's not random at all.


More information about the Digitalmars-d-learn mailing list