|
random(x) |
|
x = Any Number: e.g: 5, 4376, 34.88...
Example:
random(x) will return any number between 0 and x, 0 included but always smaller than x, these include integers (3, 55, 67356 ,0...) and real numbers (3.5, 55.82, 67356.0, 0.7). so random(3) can return any number in the range: 0 - 2.99999999999999999999.
Be careful when using random(x) to choose whole numbers to do different things (e.g pick a number between 0 and 10, if 0 do this, if 1 do this, if 2 do this, if 3 do this...) as you may find that it seems not to work, this is usually because you're checking for whole numbers (1, 2, 3, 4, 5...) and random(x) is returning real numbers (3.67, 2.84, 1.5, 0.9) In order to produce whole numbers only, place either ceil, floor or round in front.
Example:
Revision #3 |