-
Notifications
You must be signed in to change notification settings - Fork 1
random
Daedalus1400 edited this page May 16, 2017
·
3 revisions
The random generic generates a random number within a specified range.
Added in release version 0.1.1
Must be "random".
Accepts a number. Default value is 0.
Accepts a number. Default value is 0.
The following example generates a random floating point value between 5.0 (inclusive) and 20.0 (exclusive):
{"type": "random", "lowerbound": "5", "upperbound": "20"}
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.