C rand() in Ruby

Is there some simple way to make use of C’s rand() from within Ruby?
The daughter of someone I know is writing some toy scripts to compare
PRNG results for a science fair project . . .

ara.t.howard wrote:

On Apr 10, 2008, at 10:20 AM, Chad P. wrote:

Is there some simple way to make use of C’s rand() from within Ruby?
The daughter of someone I know is writing some toy scripts to compare
PRNG results for a science fair project . . .

you mean other than just using

rand

That would call ruby’s mersenne twister, AFAIK.

On Apr 10, 2008, at 10:20 AM, Chad P. wrote:

Is there some simple way to make use of C’s rand() from within Ruby?
The daughter of someone I know is writing some toy scripts to compare
PRNG results for a science fair project . . .

you mean other than just using

rand

??

you can directly call the C function using ruby/dl (see examples in
dist)

cheers.

a @ http://codeforpeople.com/

On Fri, Apr 11, 2008 at 03:27:53AM +0900, ara.t.howard wrote:

??
Yes, other than that – since that uses Ruby’s PRNG, and not C’s.

you can directly call the C function using ruby/dl (see examples in
dist)

Thanks.

On Apr 10, 2008, at 12:32 PM, Joel VanderWerf wrote:

That would call ruby’s mersenne twister, AFAIK.

yeah - i just wasn’t clear on what was being asked - ruby/dl is the
ticket me thinks…

a @ http://codeforpeople.com/

On Fri, Apr 11, 2008 at 03:32:09AM +0900, Joel VanderWerf wrote:

That would call ruby’s mersenne twister, AFAIK.

Indeed – which is why I was asking about C’s rand() function.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs