Random number generator (included): Difference between revisions

m
→‎{{header|FutureBasic}}: Added information
m (→‎{{header|FutureBasic}}: Added information)
Line 317:
=={{header|FutureBasic}}==
Syntax:
<pre>
randomInteger = rnd(expr)
</pre>
 
This function returns a pseudo-random long integer uniformly distributed in the range 1 through expr. The expr parameter should be greater than 1, and must not exceed 65536. If the value returned is to be assigned to a 16-bit integer (randomInteger), expr should not exceed 32767. The actual sequence of numbers returned by rnd depends on the random number generator's "seed" value. (Note that rnd(1) always returns the value 1.)
 
Syntax:
<pre>
random (or randomize) [expr]
</pre>
This statement "seeds" the random number generator: this affects the sequence of values which are subsequently returned by the rnd function and the maybe function. The numbers returned by rnd and maybe are not truly random, but follow a "pseudo-random" sequence which is uniquely determined by the seed number (expr). If you use the same seed number on two different occasions, you'll get the same sequence of "random" numbers both times. When you execute random without any expr parameter, the system's current time is used to seed the random number generator.
 
Example 1:
example: random 375 // using seed number
<pre>
random // current system time used as seed
example: random 375 // using seed number
 
</pre>
This statement "seeds" the random number generator: this affects the sequence of values which are subsequently returned by the rnd function and the maybe function. The numbers returned by rnd and maybe are not truly random, but follow a "pseudo-random" sequence which is uniquely determined by the seed number (expr). If you use the same seed number on two different occasions, you'll get the same sequence of "random" numbers both times. When you execute random without any expr parameter, the system's current time is used to seed the random number generator.
Example 2:
random // current system time used as seed
</pre>
 
Example:
729

edits