This is the ThingsDB documentation for version v0, click here for the latest version!
Returns pseudo-random integer number between a given range.
The first argument specifies the start of the range and must have a value less than the
second argument when specifies the end of the range. The start is inclusive and the end is
exclusive, for example: randint(0, 2)
will return either 0
or 1
.
Do not use randint() when the purpose is security related since the linear congruential algorithms used by this function are too easy to break.
This function does not generate an event.
randint(start, end)
Argument | Type | Description |
---|---|---|
start |
int (required) | Start of the range (inclusive). |
end |
int (required) | End of the range (exclusive). |
A pseudo-random int between start
(inclusive) and end
(exclusive).
Example on how randint(..) can be used:
// Return a pseudo-random number between 10 (inclusive) and 20 (exclusive)
randint(10, 20);
Example return value in JSON format:
13