Concept Framework 2.0 documentation Contents | Index

standard.C.math.srand

Name Version Deprecated
srand version 1.0 no

Prototype:
number srand(number seed)

Parameters:
seed      [in] Seed for random-number generation

Description:
The srand function sets the starting point for generating a series of pseudorandom integers. To reinitialize the generator, use 1 as the seed argument. Any other value for seed sets the generator to a random starting point.

rand retrieves the pseudorandom numbers that are generated. Calling rand before any call to srand generates the same sequence as calling srand with seed passed as 1.

Example:
import standard.C.math
import standard.C.time

class Main {
     function Main() {
          /* Seed the random-number generator with current time so that
          * the numbers will be different every time we run.
          */
          srand(time());

          /* Display 10 numbers. */
          for(var i = 0; i < 10; i++)
               echo "" + rand() + "\n";
     }
} 
 

Results 
23308
26874
27985
8661
7135
4724
15947
4854
14226
8279  

Returns:
The srand function sets the starting point for generating a series of pseudorandom integers. To reinitialize the generator, use 1 as the seed argument. Any other value for seed sets the generator to a random starting point.

Documented by Simona Gabriela Plesuvu, generation time: Fri Jan 21 18:06:19 2011 GMT(c)2011 RadGs Software