Difference between revisions of "Rand"
Jump to navigation
Jump to search
imported>Haama m (Standardized) |
imported>QQuix (Adjusted the syntax line to match the OBSE doc) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
'''Syntax:''' | '''Syntax:''' | ||
rand | (rand:float) rand min:float max:float | ||
Returns a random number between min and max. | Returns a random number between min and max. | ||
Line 9: | Line 9: | ||
set n to rand 1 100 | set n to rand 1 100 | ||
==Notes== | |||
*This function uses the [http://en.wikipedia.org/wiki/Mersenne_Twister Mersenne Twister algorithm]. | |||
*Returns a float value with quite a few decimal places (and almost never a nice, round integer). Check the returned float against intervals (< 2, < 3, < 4, and so on) rather than against integers (==1, ==2, etc.). | |||
*Assigning the result to a Short var will truncate the decimals. (causing the Max value to almost never occur) | |||
==See Also== | ==See Also== |
Latest revision as of 06:05, 13 September 2016
A command for Oblivion Script Extender
Syntax:
(rand:float) rand min:float max:float
Returns a random number between min and max.
Example
set n to rand 1 100
Notes[edit | edit source]
- This function uses the Mersenne Twister algorithm.
- Returns a float value with quite a few decimal places (and almost never a nice, round integer). Check the returned float against intervals (< 2, < 3, < 4, and so on) rather than against integers (==1, ==2, etc.).
- Assigning the result to a Short var will truncate the decimals. (causing the Max value to almost never occur)