Skip to main content

getRandomInteger

Returns a randomly selected integer from between the given lower and upper bounds.

The lower bound is inclusive and the upper bound is exclusive. If the lower bound = 1 and the upper bound = 5, the function randomly selects and returns one of the following: 1, 2, 3, or 4.

Tip

This function returns an integer. The getRandomNumber function returns decimals.

Parameters

  • LOWER BOUND (number)

    Optional. Defines the lower bound for the return value. Must be an integer and lower than the UPPER BOUND value. The lowest possible value is -2,147,483,648. The lower bound is inclusive.

    Default: -2,147,483,648

  • UPPER BOUND (number)

    Optional. Defines the upper bound for the return value. Must be an integer and higher than the LOWER BAND value. The highest possible value is 2,147,483,647. The upper bound is exclusive.

    Default: 2,147,483,647

Examples

If the parameters are unspecified, the default values apply.

ATL in Script

Result

[[getRandomInteger()]]

An integer between -2,147,483,648 (inclusive) and 2,147,483,647 (exclusive).

[[getRandomInteger(1,'')]]

An integer between 1 (inclusive) and 2,147,483,647 (exclusive).

Use the first and second parameters to set upper and lower bounds.

ATL in Script

Result

[[getRandomInteger(1,5)]]

An integer between 1 (inclusive) and 5 (exclusive).

[[getRandomInteger(1,2)]]

The result is 1 because the LOWER BAND is exclusive.