Rand()

From TinyMUX
Revision as of 05:34, 7 September 2009 by Brazil (talk | contribs) (Both ranges are inclusive.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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