[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C functions with shared state
- From: Paul Ducklin <duck@...>
- Date: Tue, 29 May 2007 22:00:40 +1000
>The reason I ask is that, in my environment I
>don't have access to the normal srand and rand >functions in the C library. What I have is a
This isn't an answer to your question but it may be a solution to the overall problem :-)
Have a look at:
http://www.tecgraf.puc-rio.br/~lhf/ftp/lua
and specifically:
http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.0/lrandom.tar.gz
which is lhf's Mersenne Twister library for Lua.
You get a library by lhf, a Lua lesson, a really decent and trusted pseudo random number generator, and a traditionally-flavoured seed() function all in a few KB of compiled object code...
I always compile this library into my Lua binary so that I have no excuse for ending up relying on some dodgy random function (e.g. rand()/srand()).
Pseudorandoms are, well, pseudo...but you may as well be as legitimately pseudo as you can :-)