Previous: , Up: System   [Contents][Index]


20.21.2 rand

The rand built-in function has the form:

fun rand = (uint<32> seed = 0) int<32>:

It returns a pseudo-random number in the range of the unsigned 32-bit integers. If a seed different to zero is provided, it is used to initialize a new sequence of pseudo-random numbers (which includes the one returned.)

The gettime builtin function can be used in order to seed the pseudo-random number generator very easily:

srand (gettime[1])