GoFiler Legato Script Reference
Legato v 1.5d Application v 5.25a
|
Table of Contents | < < Previous | Next >> |
Chapter Seven — Math Functions (continued)
Overview
The Random function returns a random integer from 0 to 0x7FFF (32,767).
Syntax/Parameters
Syntax
int = Random ( );
Parameters
(none)
Return Value
Returns an int as a random value.
Remarks
The random number is generated by an algorithm that returns a sequence of apparently non-related numbers each time it is called. This algorithm uses a seed to generate the series, which should be initialized to some distinctive value using the SeedRandom function.
A typical way to generate trivial pseudo-random numbers in a determined range using the Random function is to use the modulo of the returned value by the range span and add the initial value of the range:
v1 = Random() % 100; // v1 in the range 0 to 99
v2 = Random() % 100 + 1; // v2 in the range 1 to 100
v3 = Random() % 30 + 1985; // v3 in the range 1985-2014
Notice though that this modulo operation does not generate uniformly distributed random numbers in the span (since in most cases this operation makes lower numbers slightly more likely).
Related Functions
Platform Support
Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL
Legato IDE, Legato Basic
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.