lua-users home
lua-l archive

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


On Mon, Mar 19, 2007 at 08:09:59PM -0300, Luiz Henrique de Figueiredo wrote:
> Lua relies on rand from libc. It must not be too clever about what it does
> with the result of rand lest it breaks its randomness (which may be weak
> already). So I think the fix for Lua is to call rand() a couple of times
> whenever the seed changes.

srand() is used to start the seed. Successive rand() calls will update the
internal seed so the next call to rand() will result in the next random
number from a sequence. Multiple calls to srand() will destroy randomness
if the seed is related to the previous seed.

Jürgen