|
Rnd | ||||
RandomInteger = Rnd(Range) | ||||
Parameters: Range = The Range value that the random number is selected within. |
||||
Returns: RandomInteger = The random number selcted by the RND function |
||||
The Rnd function will return a random number between and zero and the range value selected. This range value and zero are inclusive, so their both possible outputs of the function. Each time you use the RND() function it will return a different result. While Rnd may appear to produce random results to us humans, the results it produces are in fact part of a 'set'. The size of these sets, will in the millions however, so it's unlikely you'll noticed the values repeating, but they do repeat. This is not a PlayBASIC issue, it's an issue with how random number generation techniques employed in computers. FACTS: * The value returned by the Rnd function is inclusive of zero and the range limit. * See Randomize to seed the random number generator EXAMPLES Example #1: 10 Random Numbers Displaying a list of 10 random numbers between 0 and 100 (inclusive)
This example could output something like this. (could as it'll be random set of results each time you run the program)
Example #2: Using Randomize to seed RND generator In this example we're going to display a set of random numbers, but with one key difference to the above. This time by using the RANDOMIZE command to seed the random number geneator, we can be sure that set of randoms generated, will always be the same.
This example could output something like this. (could as it'll be random set of results each time you run the program)
|
Related Info: | Randomize | Rnd# | RndRange | RndRange# : |
|
|||||||||||||||||||||||||||||||||||||||
(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com |