Rand()
Description
FUNCTION: rand(num)
FUNCTION: rand(lower, upper)
In the first form, rand() returns an integer between 0 and num-1, inclusively. In the second form, rand() returns an integer between lower and upper, inclusively. Each integer within the range is equally likely to be returned by rand() – a flat distribution.
Related Topics: die(), lrand(), pickrand(), shuffle().
Examples
> say rand(10)
You say “6”
> say rand(10)
You say “1”
> say rand(-1,2)
You say “0”
(–Soylent 01:46, 3 December 2005 (EST))