in reply to Getting srand's seed
There are two possibilities: it is (as you suggest) easy, or it is impractical. Given that the srand documentation doesn't describe a way to do it I'd guess it is impractical.
A workaround that may be good enough for you is:
my $srandSeed = rand (2**31); srand ($srandSeed);
which uses the standard technique for seeding, then reseeds using the first "random" number generated. Note however that Perl's built in rand has many problems that may be an issue depending in your application. For serious work you would be much better using Math::Random::MT or one of the other random number generating modules.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting srand's seed
by fangly (Initiate) on Oct 10, 2008 at 01:55 UTC | |
by GrandFather (Saint) on Oct 10, 2008 at 02:43 UTC | |
by fangly (Initiate) on Oct 10, 2008 at 03:26 UTC | |
by GrandFather (Saint) on Oct 10, 2008 at 05:36 UTC | |
by fangly (Initiate) on Oct 10, 2008 at 18:41 UTC | |
by moritz (Cardinal) on Oct 10, 2008 at 06:22 UTC |