Rnd function
Describe
Returns a random number.
Grammar
rnd[(number)]
The number argument can be any valid numeric expression.
Description
The RND function returns a value less than 1 but greater than or equal to 0. The value of number determines how the Rnd generates random numbers:
If number is Rnd generated
is less than 0 each time the same value, using number as the seed.
is greater than the next random number in the 0 sequence.
equals zero The most recently generated number.
Omits the next random number in the sequence.
Because each successive call to the RND function uses the previous number in the sequence as the seed of the next number, the same sequence is generated for any initially given seed.
Before calling Rnd, the random number generator is initialized with a Randomize statement without parameters, which has seeds based on the system timer.
To produce a random integer of the specified range, use the following formula:
Int ((upperbound-lowerbound + 1) * Rnd + lowerbound)
Here, the upperbound is the upper bound of this range, and the lowerbound is the lower bound within this range.
--------------------------------------------------------------------------------
Note to repeat the sequence of random numbers, call Rnd with a negative argument immediately before you call Randomize with a numeric argument. Randomize that use the same number value cannot repeat the previous sequence of random numbers.
---------------------------------
Example:
We usually use now to do the seed, so we can get the perfect random sequence, if we need a random number within 1-100
Randomize ()
N=int ((100-1+1) *rnd (now ()) +1)