Skip to content
Daedalus1400 edited this page May 16, 2017 · 3 revisions

Description:

The random generic generates a random number within a specified range.

Added in release version 0.1.1

Arguments:

type

Must be "random".

upperbound

Accepts a number. Default value is 0.

lowerbound

Accepts a number. Default value is 0.

Example Usage:

The following example generates a random floating point value between 5.0 (inclusive) and 20.0 (exclusive):

{"type": "random", "lowerbound": "5", "upperbound": "20"}

Notes:

This is implemented as

java.util.random.nextDouble() * (upperbound - lowerbound) + lowerbound;

where java.util.random.nextDouble() generates a floating point value between 0.0 (inclusive) and 1.0 (exclusive). As such, positive and negative values can be used for either bound. If both bounds are the same then the system will generate an error during initialization since then this object would only output a single number and that is the job of a numeric literal, not a random number generator.

Clone this wiki locally