Last edit: @jheafpp in #[IM @jheafpp] 4 months ago - Slack Archive

print(math.rand()*6)

History

Revision: 4735 (deleted) by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

local A1, A2 = 727595, 798405  -- 5^17=D20*A1+A2
local D20, D40 = 1048576, 1099511627776  -- 2^20, 2^40
local X1, X2 = 0, 1
function rand()
    local U = X2*A2
    local V = (X1*A2 + X2*A1) % D20
    V = (V*D20 + U) % D40
    X1 = math.floor(V/D20)
    X2 = V - X1*D20
    return V/D40
end

print(to_number(rand()*6))

Revision: 4727 by @jheafpp in #[IM @jheafpp] 4 months agoSlack Archive

print(math.rand()*6)