Rand()

From TinyMUX
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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))