ssc/stdlib/random.sun
arookas ca8f59dea2 Added RNG utility functions.
Intentionally did not import it in common.sun.
2016-01-31 14:32:36 -05:00

18 lines
420 B
Text

/* ================================================= *\
* random.sun
*
* ssc standard include utility
* 2016 arookas
\* ================================================= */
var __RAND_NEXT;
function srand(seed) {
__RAND_NEXT = seed;
}
function rand() {
// this is exactly the formula used in MSL (and, thus, SMS itself)
__RAND_NEXT = (__RAND_NEXT * 1103515245) + 12345;
return (__RAND_NEXT >> 16) & 0x7FFF;
}