Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 667 of 909
RANDOM=formula
Random Number
APPLICATION: Math function
DESCRIPTION: Seeds the random number generator; gets (reads) the next
value from the random number generator
EXECUTION: Immediate
CONDITIONAL TO: Previous calls to RANDOM
LIMITATIONS: N/A
READ/REPORT: RRANDOM
WRITE: Read/write
LANGUAGE ACCESS: Assignment, formulas and conditional testing
UNITS: N/A
RANGE OF VALUES: Output:0 to 2147483647
Input: -2147483648 to 2147483647
TYPICAL VALUES: Output:0 to 2147483647
Input: -2147483648 to 2147483647
DEFAULT VALUE: N/A
FIRMWARE VERSION: 5.x and later
COMBITRONIC: N/A
DETAILED DESCRIPTION:
The RANDOMcommand is used to get (read) the next value from the pseudorandom number
generator. RANDOM can also be assigned to seed the random-number generator.
l
RANDOM=formula
Sets the random seed value. Any 32-bit value is accepted.
l
x=RANDOM
Gets the next value from the random number generator and assigns it to the variable x.
The output of the random number generator is an integer (whole number) in the range from 0
to 2147483647.
The number generated is not truly random— it does follow a predictable sequence if the
starting point (seed) and algorithm are known. This allows a test sequence to be repeated and
use the random generator to exercise a wide range of values. However, if this were used in
programs expecting unpredictability (e.g., a game or secret number generator), the results
may be disappointing.
If an unpredictable seed is desired, then a more creative approach must be used to initialize
the value based on events in the real world. For example, you could measure the time
between some real-world inputs that are somewhat random.
Part 2: Commands: RANDOM=formula