Difference between revisions of "Math.random"
From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2011.6<br/> === Description === This function is an interface to the simple pseudo-random generator function rand provided by ANSI C....") |
|||
Line 7: | Line 7: | ||
When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number m, math.random returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n]. | When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number m, math.random returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n]. | ||
<source lang="lua"> | <source lang="lua"> | ||
− | (number) | + | (number) = math.random(n,u) |
</source> | </source> | ||
− | '''n | + | '''n''': (number) upper limit if only n provided, lower limit if u also provided '''optional'''<br/> |
− | '''u | + | '''u''': (number) upper limit '''optional'''<br/> |
'''Returns''' (number) pseudo random number<br/> | '''Returns''' (number) pseudo random number<br/> |
Revision as of 10:17, 23 August 2018
Available since: Gideros 2011.6
Description
This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. (No guarantees can be given for its statistical properties.)
When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number m, math.random returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n].
(number) = math.random(n,u)
n: (number) upper limit if only n provided, lower limit if u also provided optional
u: (number) upper limit optional
Returns (number) pseudo random number