On Mon, Dec 22, 2008 at 7:27 PM, Daniel Finnie <dan / danfinnie.com> wrote: > Hi, I was wondering about this expression and its siblings: > >> Math.sin(rand(2 * Math::PI)) > > The documentation > <http://www.ruby-doc.org/core/classes/Kernel.html#M005977>states that > rand(num) will pick a random integer between 0 and num.abs.to_i > (unless this is different in JRuby). Therefore, the only values that can > come out of this expression are sin(0), sin(1), ... sin(6) which are 0, > .841, .909, .141, -.757, -.960, and -.279 (of course these are different for > cosine). Is it just the range -1<y<1? Would rand(2)-1 suffice? What is > the significance of these numbers and doing rand(2pi) instead of rand(6)? No significance other than trying to finish before 1:00. :-) Maybe I was thinking: sin(rand * 2 * PI? But, yeah rand * 2 - 1 would have sufficed there. Thanks.