Discussion: rand() v. rand(0.1) ?
Afficher un message
Vieux 15/09/2007, 12h35   #3
Chad Perrin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: rand() v. rand(0.1) ?

On Sat, Sep 15, 2007 at 08:11:25PM +0900, Florian Frank wrote:
> 7stud -- wrote:
> >Is there any difference between calling rand() and rand(0.1)?
> >

> ------------------------------------------------------------ Kernel#rand
> rand(max=0) => number
> ------------------------------------------------------------------------
> Converts _max_ to an integer using max1 = max+.to_i.abs+. [...]
>
> No.


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. I'd prefer some kind of a general feel for it before I
write software to statistically analyze the output of millions of
iterations of rand() evaluations.

--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
Dr. Ron Paul: "Liberty has meaning only if we still believe in it when
terrible things happen and a false government security blanket beckons."

  Réponse avec citation
 
Page generated in 0,04474 seconds with 9 queries