Format
number1 = RND (number2)
Description
This statement will return an integer number in the range of 0 through
32767 for normal integers, and in the range of 0 to 2,147,483,647 for long
integers. This random number will be stored in number1. Number2 is a dummy
argument and can be any valid integer value. If number1 is a decimal
variable, the random number returned will be an integer in the range of 0
to 2,147,483,647.
Example 1
A& = RND(0)
After execution of this statement "A" will contain a number between 0 and
2,147,483,647 inclusive.
Example 2
RANDOMIZE
DIEROLL=RND(0)
DIEROLL=DIEROLL MOD 6
DIEROLL=DIEROLL+1
PRINT "YOU ROLLED A";DIEROLL
The above example demonstrates how to generate a number in a given range.
In this case, the range will be 16, which would be suitable for simulating
the roll of a die. The above example will generate the simulated die roll,
and print the result.
Comments
In BASICA/GWBASIC, RND always returns a value between 1 and 0.
