lua-users home
lua-l archive

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


Large seeds get truncated (5.1)
See http://lua.2524044.n2.nabble.com/Unexpected-randomseed-results-was-ANN-uuid-pure-Lua-uuid-generator-td7649168.html

Thijs



-------- Oorspronkelijk bericht --------
Van: Dirk Laurie <dirk.laurie@gmail.com>
Datum:
Aan: Lua mailing list <lua-l@lists.lua.org>
Onderwerp: Re: PRNG for Lua 4.0?


2013/9/10 Michael Horvath <mikh2161@gmail.com>:

> The output is "24".

OK. That means you have 24-bit floating-point.

You can use the same code, but you will have to make all
the constants much smaller. The a,c,m values must be
small enough that a*(m-1) + c is less than 2^24.

Do you have access to Knuth's Art of Computer Programming,
Volume 2? I think he has some tables of good a,c,m values
for low-precision machines.