[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: rand() v. rand(0.1) ?

Yukihiro Matsumoto

9/15/2007 12:10:00 PM

Hi,

In message "Re: rand() v. rand(0.1) ?"
on Sat, 15 Sep 2007 20:35:37 +0900, Chad Perrin <perrin@apotheon.com> writes:

|Speaking of which . . . obviously rand() doesn't produce a truly random
|number, but it's reasonably close for some purposes. I'm curious about
|just how far off it is, though -- because I'm curious about how
|appropriate it is to use to simulate dice-rolling for gaming software (in
|the "roleplaying game" sense of the term "gaming") in Ruby's
|implementation.

It uses Mersenne Twister algorithm which has a period of 2**19937-1.

matz.

1 Answer

Chad Perrin

9/15/2007 1:44:00 PM

0

On Sat, Sep 15, 2007 at 09:09:52PM +0900, Yukihiro Matsumoto wrote:
> Hi,
>
> In message "Re: rand() v. rand(0.1) ?"
> on Sat, 15 Sep 2007 20:35:37 +0900, Chad Perrin <perrin@apotheon.com> writes:
>
> |Speaking of which . . . obviously rand() doesn't produce a truly random
> |number, but it's reasonably close for some purposes. I'm curious about
> |just how far off it is, though -- because I'm curious about how
> |appropriate it is to use to simulate dice-rolling for gaming software (in
> |the "roleplaying game" sense of the term "gaming") in Ruby's
> |implementation.
>
> It uses Mersenne Twister algorithm which has a period of 2**19937-1.

Excellent! Thank you for the quick and informative response.

--
CCD CopyWrite Chad Perrin [ http://ccd.ap... ]
Amazon.com interview candidate: "When C++ is your hammer, everything starts
to look like your thumb."