Kaya 0.5.2 reference for Builtins::rand

List of functions and data types in Builtins

Int rand()

Usage

rand() returns a pseudo-random signed integer in the range +/- (2**31)-1

You must call srand before the first call to this function in a program.

srand(12345);
for i in [1..5] {
    putStr(rand()+" ");
}

Gives: 1995772607 -612336503 -885735441 457910745 1875493919

The rand() function is a low-quality but fast generator - for better quality numbers, use the optional Lfrand module or for cryptographic purposes, your computer's hardware RNG.

Related

kaya@kayalang.org | Last modified 13 July 2009 | Supported by Durham CompSoc | Powered by Kaya