Difference between revisions of "Core.random"

From GiderosMobile
(----)
Line 1: Line 1:
__NOTOC__
+
'''Available since:''' Gideros 2017.9<br/>
<languages />
+
'''Class:''' [[Core]]<br/>
'''<translate>Available since</translate>:''' Gideros 2017.9<br/>
+
 
'''<translate>Class</translate>:''' [[Special:MyLanguage/Core|Core]]<br/>
+
=== Description ===
=== <translate>Description</translate> ===
+
Generate and return a pseudo random number. The random number sequence is guaranteed to be consistent across devices for a given seed.
<translate>Generate and return a pseudo random number. The random number sequence is guaranteed to be consistent across
+
 
  devices for a given seed.
+
 
  If bounds aren't specified, the function will return a floating point number between 0 and 1.
+
If bounds aren't specified, the function will return a floating point number between 0 and 1.
  If one bound is specified, the function will return an integer number between 1 and that bound (inclusive).
+
If one bound is specified, the function will return an integer number between 1 and that bound (inclusive).
  If both bounds are specified, the function will return an integer between bound1 and bound2. bound2 must be greater than bound1.</translate>
+
If both bounds are specified, the function will return an integer between bound1 and bound2. bound2 must be greater than bound1.
 +
 
 +
 
 
<source lang="lua">
 
<source lang="lua">
 
() = Core.random(generator,bound1,bound2)
 
() = Core.random(generator,bound1,bound2)
 
</source>
 
</source>
=== <translate>Parameters</translate> ===
+
 
'''generator''': (number) <translate>PRNG algorithm to use, use 0 for default engine (MT19937)</translate> '''optional'''<br/>
+
=== Parameters ===
'''bound1''': (number) <translate>First bound of the range returned number must be in</translate> '''optional'''<br/>
+
'''generator''': (number) PRNG algorithm to use, use 0 for default engine (MT19937) '''optional'''<br/>
'''bound2''': (number) <translate>Second bound of the range returned number must be in</translate> '''optional'''<br/>
+
'''bound1''': (number) First bound of the range returned number must be in '''optional'''<br/>
=== <translate>Return values</translate> ===
+
'''bound2''': (number) Second bound of the range returned number must be in '''optional'''<br/>
'''<translate>Returns</translate>''' () <translate>random number</translate><br/>
+
 
 +
=== Return values ===
 +
'''Returns''' () random number<br/>
 +
 
 +
----
 +
{{Special:PrefixIndex/Core}}
 +
<br/>

Revision as of 18:01, 2 December 2019

Available since: Gideros 2017.9
Class: Core

Description

Generate and return a pseudo random number. The random number sequence is guaranteed to be consistent across devices for a given seed.


If bounds aren't specified, the function will return a floating point number between 0 and 1. If one bound is specified, the function will return an integer number between 1 and that bound (inclusive). If both bounds are specified, the function will return an integer between bound1 and bound2. bound2 must be greater than bound1.


() = Core.random(generator,bound1,bound2)

Parameters

generator: (number) PRNG algorithm to use, use 0 for default engine (MT19937) optional
bound1: (number) First bound of the range returned number must be in optional
bound2: (number) Second bound of the range returned number must be in optional

Return values

Returns () random number