Closed qoala closed 8 months ago
https://discord.com/channels/313015356052471828/313015598789427202/1159912000344825927
local function next( self )
-- http://remus.rutgers.edu/~rhoads/Code/random.c
-- LUA:
-- Our assumption is that double-precision is encoded with 64 bits (according to IEEE 754)
-- We have enough precision to handle all 32 bit unsigned integer representations, and calculate
-- modulo 2^32 to generate single-point precision random values.
local a, m, q, r1, r2 = 1588635695, 4294967291, 2, 17054, 44957
local s1, s2 = math.floor(self._seed / (2^17)), (math.floor(self._seed / 2) % (2^16))
local p = (r2 * s2) + (2^16) * r1 * s2 + (2^16) * r2 * s1 -- r1 * s1 are MSB and discarded
self._seed = a*(self._seed % q) - p
self._seed = self._seed % (2^32)
return self._seed / m
end
https://discord.com/channels/313015356052471828/313015598789427202/1138490245969625108
Cyberboy2000