srand - seed the pseudo-random number generator


<srand $seed>

The srand function "seeds" the pseudo-random number generator with an integer $seed, which determines what sequence of pseudo-random numbers will be returned in future calls to rand and randpick. This can be used to help ensure the sequence is different each run (with a random seed), or to generate the same sequence on a subsequent run (with the same seed) i.e. for reproducibly random results.

If an empty string is given, a semi-random seed is created; this is also how the generator is seeded if srand is not called.

The srand function returns the previous seed value.


<srand 12345>
  <WHILE $loop lt 10>
    <rand 0 10> $ret

The output will always produce the same sequence of "random" numbers on a given platform.

The srand function was added Mar. 16 2000.

The reproducibility and/or randomness of numbers is system-dependent.

rand, randpick

Copyright © Thunderstone Software     Last updated: Oct 24 2023
Copyright © 2024 Thunderstone Software LLC. All rights reserved.