RE: Separate threads of random numbers
- Posted by Andy Serpa <renegade at earthling.net> Apr 07, 2002
- 389 views
Thanks, Pete. Sometimes I am so stupid. The more obvious something is the less chance I have to notice it. I wrote something almost identical except I didn't set the seed EVERY time I got a value as I should, but only when I was switching threads. When I realized that didn't work, my brain apparently threw out the whole concept... petelomax at blueyonder.co.uk wrote: > On Sun, 7 Apr 2002 14:10:25 +0000, Andy Serpa > <renegade at earthling.net> wrote: > > How about doing this: > init(): > set_rand(12345) > seed[1]=rand(1073741823) -- use max range for thread seeds > seed[2]=rand(1073741823) > seed[3]=rand(1073741823) > > & > function get_next_rand(integer thread, integer limit) > integer result > set_rand(seed[thread]) > result=rand(limit) > seed[thread]=rand(1073741823) > return result > > Pete > >