From: David Stanislaus Date: 2008-06-10T10:44:26+09:00 Subject: Re: Random Number Stuff Oh man... It's probably faster to show you what I do understand, but I'm just goint to show you what I don't... Pe単a, Botp wrote: > From: stanislaus_d@hotmail.com [mailto:stanislaus_d@hotmail.com] > # How would you create a random number generator thats limited to a > # specific rang? say 1930 - 1950 > > botp@botp-desktop:~$ qri rand > ------------------------------------------------------------ Kernel#rand > rand(max=0) => number > ------------------------------------------------------------------------ > Converts max to an integer using max1 = max.to_i.abs. If the > result is zero, returns a pseudorandom floating point number > greater than or equal to 0.0 and less than 1.0. Otherwise, returns > a pseudorandom integer greater than or equal to zero and less than > max1. Kernel::srand may be used to ensure repeatable sequences of > random numbers between different runs of the program. Ruby > currently uses a modified Mersenne Twister with a period of > 2**19937-1. > [none of this but I don't think it is really necessary for my question so we can just disregard it] > so, > [whats irb whats all this main stuff and things, why is 1930 out side and added to the rand couldn't I just use rand(1950 - 1930)??? and maybe if I showed you what I was trying to do. http://pine.fm/LearnToProgram/?Chapter=06 the bottom Deaf Grandma.] > irb(main):007:0> 1930 + rand(1950 - 1930) > => 1940 > irb(main):008:0> 1930 + rand(1950 - 1930) > => 1932 > irb(main):009:0> 1930 + rand(1950 - 1930) > => 1947 > > kind regards -botp Urgh, I know I really don't understand ruby at all. -- Posted via http://www.ruby-forum.com/.