ProvideX V8.20 > Language Reference > 3. System Functions
511
RND( ) Function
          Return Random Number
Format
RND(seed[,ERR=stmtref])
Where:
seed
Numeric expression must be (or result in) an integer. The value of this
number is used to determine the result of the function.
stmtref
Program line number or label to transfer control to.
Returns
Random numbers based on given value.
Description
The RND( ) function returns random numbers based on the seed given. The
following table describes the value returned based on the seed value:
If seed is greater than 0 zero, the random number returned will be in the
>0
range of zero to one less than the given number (to a maximum of 32768).
If seed equals 0 zero, the random number returned will be between 0 and 1,
=0
with PRECISION=8.
If seed is less than 0 zero, RND( ) initializes the seed for generating the next
<0
sequence of random numbers, similar to use of the RANDOMIZE directive.
When seed is 0 or greater, each call to the RND( ) function will yield a different random
number. Executing the RANDOMIZE directive and using the RND( ) function with a
negative value will produce similar results; e.g.,
RANDOMIZE 10
RANDOMIZE 10
=
=
?RND(-10)
?RND(0)
?RND
For further randomization, use RND(-TME) as a method to re-initialize the seed value.
Note: ProvideX returns an error when seed is greater than 2147483647 or is not a valid
integer.
See Also
RANDOMIZE Directive, p.268
RND System Variable, p.569
Example
0010 REM
0020 FOR I=1 TO 10
0030 PRINT RND(9),
0040 NEXT
0050 PRINT 'LF',RND(0)
0060 PRINT RND(-1)
0070 PRINT " DONE"; END
-:run
1170774457
0.05947216
0.11337858
DONE