ssc/stdlib/random.sun

19 lines
420 B
Text
Raw Normal View History

/* ================================================= *\
* 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;
}