Difference between revisions of "Math.random"
From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>") |
|||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
'''Available since:''' Gideros 2011.6<br/> | '''Available since:''' Gideros 2011.6<br/> | ||
+ | '''Class:''' [[math]]<br/> | ||
+ | |||
=== Description === | === 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.) | |
+ | <syntaxhighlight lang="lua"> | ||
+ | (number) = math.random(n,u) | ||
+ | </syntaxhighlight> | ||
+ | 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]. | ||
− | |||
− | |||
− | |||
− | |||
=== Parameters === | === Parameters === | ||
− | '''n''': (number) | + | '''n''': (number) upper limit if only n provided, lower limit if u also provided '''optional'''<br/> |
− | '''u''': (number) | + | '''u''': (number) upper limit '''optional'''<br/> |
+ | |||
=== Return values === | === Return values === | ||
− | '''Returns''' (number) | + | '''Returns''' (number) pseudo random number<br/> |
+ | |||
+ | === See Also === | ||
+ | '''[[Core.random]]''' | ||
+ | |||
+ | {{Math}} |
Latest revision as of 14:31, 13 July 2023
Available since: Gideros 2011.6
Class: math
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.)
(number) = math.random(n,u)
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].
Parameters
n: (number) upper limit if only n provided, lower limit if u also provided optional
u: (number) upper limit optional
Return values
Returns (number) pseudo random number
See Also
- Math
- Math.abs
- Math.acos
- Math.asin
- Math.atan
- Math.atan2
- Math.ceil
- Math.clamp
- Math.cos
- Math.cosh
- Math.cross
- Math.deg
- Math.distance
- Math.distances
- Math.dot
- Math.edge
- Math.exp
- Math.fft
- Math.floor
- Math.fmod
- Math.frexp
- Math.ifft
- Math.inside
- Math.ldexp
- Math.length
- Math.log
- Math.log10
- Math.max
- Math.min
- Math.modf
- Math.nearest
- Math.noise
- Math.normalize
- Math.pow
- Math.rad
- Math.random
- Math.randomseed
- Math.raycast
- Math.round
- Math.sign
- Math.sin
- Math.sinh
- Math.sqrt
- Math.tan
- Math.tanh