RND Function

Returns a random number.

Syntax

RND(expression)

Syntax Elements

expression is any valid DataBasic expression that evaluates to a positive integer.

Comments

RND generates a random number between zero and the number specified by expression minus one.

expression must be a positive number. If a negative number is used, it is converted to the absolute value (the program performs an implicit ABS on the input argument).

Examples

Z = RND(11)

Assigns a random number between 0 and 10 (inclusive) to variable Z.

R = 100
Q = 50
B = RND(R+Q+1)

Assigns a random number between 0 and 150 (inclusive) to variable B.

Y = RND(-51)

Assigns a random number between 0 and 50 inclusive to variable Y.