Cicode Programming Reference > Cicode Function Categories > Math and Trigonometry Functions Introduction > Rand

Rand

Generates a random number between 0 and a specified maximum number less one.

The Rand function is zero-based, so the resultant number generated will range from zero to one less than the number provided in the Maximum argument.

Syntax

Rand(Maximum)

Maximum:

The maximum number. This number needs to be between 2 and 32767 (inclusive).

Return Value

A random number of integer type.

Example

Variable=Rand(101);
! Sets Variable to a random number from 0 to 100.
// To create a random number between 0 and 1 with 2 decimal places, divide the above variable by 100, as shown here: //
Variable = Variable/100;

See Also

Math/Trigonometry Functions