Class Random

Introduction

This class generates pseudorandom numbers, booleans, or characters. It uses the Synergy/DE built-in subroutine RANDM, so it inherits its degree of randomness.

Contents

  1. Introduction
  2. Contents
  3. Explanation of symbols used
  4. Member reference
    1. (constructors)
    2. Next - next random number
    3. NextBool - random true or false
    4. NextChars - random characters
    5. NextInt - random 32-bit integer
    6. NextLong - random 64-bit integer
    7. Seed1, Seed2 - seed values

Explanation of symbols used

Words in italics indicate an instance of a class. The word corresponds to the class name, except where more than one instance is represented in the same statement. In that case a number (2, 3, etc.) is appended to the class name.

Words in normal typeface are to be taken literally (required punctuation, class name in a static reference, method name, etc.)

The symbol => is used to separate an expression (on the left) from its return value (on the right).

An ellipsis (...) indicates that the previous argument may be repeated any number of times. The description will indicate whether one instance is required.

Member reference

constructors

new Random() => Random
new Random(int, int2) => Random
Creates a new random number generator. If int and int2 are passed, they will be used as the initial values for Seed1 and Seed2. Otherwise, a value for each will be derived from the current system time.

method Next

Random.Next() => int
This method returns the next random number in the sequence. Its value will be between 0 and 32767, inclusive. To generate numbers in other ranges, see NextInt, NextLong, and NextDec.

method NextBool

Random.NextBool() => boolean
This method returns a pseudorandom true or false, emulating a coin toss.

method NextChars

Random.NextChars(a)
Random.NextChars(a, int, int2)
This method fills a (which must therefore be writable) with random characters. If passed, int specifies the minimum ASCII character value to include, and int2 specifies the maximum. If not passed, these are assumed to be 0 and 255, respectively.

method NextInt

Random.NextInt() => int
Random.NextInt(int2) => int
Random.NextInt(int3, int2) => int
This method returns a 32-bit pseudorandom integer value. If passed, int2 is the maximum value to return, and int3 is the minimum value (both of which may be negative). If int2 or int3 are not passed, then they are assumed to be the maximum positive integer value (^x(7FFFFFFF)) and 0, respectively. If int3 is greater than int2, a Synergex.SynergyDE.SynArgumentException will be thrown. If the difference between int3 and int2 is greater than the maximum positive integer value, the result is not guaranteed to be within the specified range.

method NextLong

Random.NextLong() => long
Random.NextLong(long2) => long
Random.NextLong(long3, long2) => long
This method returns a 64-bit pseudorandom integer value. If passed, long2 is the maximum value to return, and long3 is the minimum value (both of which may be negative). If long2 or long3 are not passed, then they are assumed to be the maximum positive long value (^x(7FFFFFFFFFFFFFFF)) and 0, respectively. If long3 is greater than long2, a Synergex.SynergyDE.SynArgumentException will be thrown. If the difference between long3 and long2 is greater than the maximum positive long value, the result is not guaranteed to be within the specified range.

Seed1, Seed2

Random.Seed1 => int
Random.Seed1 = int
Random.Seed2 => int
Random.Seed2 = int
These public members represent the seed values for the random number sequence. Only the low-order 15 bits of either of these values are significant, because the internal random sequence is limited to values between 0 and 32767. Because the pseudorandom algorithm is deterministic, setting the seeds to a specific pair of values will always result in the same sequence.