[Date Prev][Date Next][Thread Prev][Thread Next]
- 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:
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 :-)