


Chipmunk basic random number code#
At that time 90% of business code was in COBOL but 60% of that done by students was in BASIC (when they weren’t doing their FORTRAN homework). Russ Walter suggested changes in January/February 1977 issue of Personal Computing Magazine. Here, upperbound is the highest number in the range, and lowerbound is the lowest number in the range.Twitter’s Trammell Hudson highlights an article from 1977 where it was suggested adopting Python-like syntax in BASIC. randomValue = CInt(Math.Floor((upperbound - lowerbound + 1) * Rnd())) + lowerbound To produce random integers in a given range, use the following formula.
Chipmunk basic random number generator#
The value of Number determines how Rnd generates a random number.įor any given initial seed, the same number sequence is generated because each successive call to the Rnd function uses the previously generated number as a seed for the next number in the sequence.īefore calling Rnd, use the Randomize statement without an argument to initialize the random-number generator with a seed based on the system timer. The Rnd function returns a value less than 1, but greater than or equal to zero. ' Initialize the random-number generator.ĭim value As Integer = CInt(Int((6 * Rnd()) + 1)) This example uses the Rnd function to generate a random integer value in the range from 1 to 6. If number is not supplied, Rnd generates the next random number in the sequence. If number is equal to zero, Rnd generates the most recently generated number. If number is greater than zero, Rnd generates the next random number in the sequence. If number is less than zero, Rnd generates the same number every time, using Number as the seed. A Single value or any valid Single expression.
