Page 1 of 1

Simple question about rand()

PostPosted: Sat Feb 25, 2006 8:05 am
by Troodon
Is this:
rand(1*10)
meaning 1 to 10
And is this:
rand(2*10)
meaning 2 to 10 or 1 to 20?

Re: Simple question about rand()

PostPosted: Sat Feb 25, 2006 10:04 am
by Fuzzy
tekdino wrote:Is this:
rand(1*10)
meaning 1 to 10
And is this:
rand(2*10)
meaning 2 to 10 or 1 to 20?


0 to 19 i believe. use rand(20)+1 to get 1-20. rand(19)+2 would be 2-21.

If you want to get 2-20, use (rand(10)+1)+(rand(10)+1)

using a simple rand statement is going to get you a flat probability; equal chances of all numbers. once you start adding them together, it creates a bell curve with the average being favoured.