lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


BTW, there's always a simple replacement for rand() suggested by Knuth,
as quoted in Numerical Recipes:

do
	local x=0
	local a=1664525
	local c=1013904223
	function randomseed(s)
		x=s
	end
	function rand()
		x=a*x+c
		return x
	end
end

http://www.library.cornell.edu/nr/bookcpdf/c7-1.pdf

This is suitable for 32-bit integers.

--lhf