in reply to Re: How do I make a random shuffle deterministic?
in thread How do I make a random shuffle deterministic?
Most implementations of "srand" take an integer and will silently truncate decimal numbers. This means "srand(42)" will usually produce the same results as "srand(42.1)". To be safe, always pass "srand" an integer.most strings will evaluate to 0 !
You need a checksum to produce a (pseudo) unique integer. You could tryDB<116> srand 0 => 1 DB<117> rand => "0.17082803610629" DB<118> rand => "0.749901980484964" DB<119> srand hostname => 1 DB<120> rand => "0.17082803610629" DB<121> rand => "0.749901980484964" DB<122> 0+ hostname => 0
$seed += ord($_) for split //, hostname
But whats wrong with the IP?
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do I make a random shuffle deterministic?
by Anonymous Monk on Dec 05, 2012 at 17:32 UTC | |
by LanX (Saint) on Dec 05, 2012 at 17:37 UTC | |
by Anonymous Monk on Dec 05, 2012 at 17:46 UTC | |
by LanX (Saint) on Dec 05, 2012 at 17:53 UTC | |
by Anonymous Monk on Dec 06, 2012 at 15:07 UTC | |
by LanX (Saint) on Dec 06, 2012 at 15:31 UTC | |
by DrHyde (Prior) on Dec 06, 2012 at 11:58 UTC |