RAndomizing Numbers
Author 
Message 
noobprogrammer123

Posted: Tue Mar 23, 2004 7:40 am Post subject: RAndomizing Numbers 


I need a little help with randomizing numbers, is there any way to set a limit to the numbers such as between 1 and 10






Sponsor Sponsor



TheZsterBunny

Posted: Tue Mar 23, 2004 8:01 am Post subject: (No subject) 


by number I assume you mean integer.
if you are assigning to a variable, there are 2 ways to do it.
var numbr : int
1) randint(numbr,1,10)
or
2) numbr := Rand.Int(1,10)
If you are doing a calculation and do not need to store the number, I recommend using the second option.
If you did not mean integer then you can do this.
var numbr2 : real
numbr2 := Rand.Real*Rand.Int(1,10)
The way these rand functions work is like this
randint (numbr,1,10)
number is your assigning variable
1 is your minimum number
10 is your maximum number
rand or Rand.Real returns a real number between 0 and 1 (some random decimal)
bunny







