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


14.20.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 get_time builtin function can be used in order to seed the pseudo-random number generator very easily:

srand (get_time[1])