Quote:
Originally Posted by Starfire2001
No.
random(1,3) gives you a random number between 1 and 3 (though never the high number, in this case 3.) So for example, random(1,3) might give you 2.5, or 1.72, etc.
int() then rounds the number down to the nearest integer. (so 2.5 becomes 2, 1.99 becomes 1.)
So
PHP Code:
this.number = int(random(1,3));
Would randomly select either 1 or 2.
|
Ah I didn't remember if it did show the higher number. I was being safe.. also he said 1 or 3.. not 1 to 3.. ? so
PHP Code:
this.number = 1 + int(random(0,2))*2;
Would do 1.. plus it resulted in 1.. it added 1*2.. so it was either 1 or 3.