rand()

Type     [GD]

function

Library   [BL]

core

Return value

number

See also

math.random (of Lua)


Overview


This function is the alias of math.random


Syntax


rand()

rand(upper)

rand(lower, upper)

rand(lower1, upper1,  lower2, upper2)


rand() with no arguments generates a real number between 0 and 1.

rand(upper) generates integer numbers between 1 and upper (both inclusive).

rand(lower, upper) generates integer numbers between lower and upper (both inclusive).


rand(lower1, upper1,  lower2, upper2) returns integer numbers bewteen lower1 and upper1 (both inclusive) or lower2 and upper2 (both inclusive).  For example


        rand(-10,-7, 10,13)


returns one of   -10,-9,-8,-7, 10,11,12,13   randomly.

댓글 없음:

댓글 쓰기