Credit Counseling | Remortgaging | Mortgages | Aluminium Die Casting | Tax
setting Random range in pascal [Archive] - PCMech Forums

PDA

View Full Version : setting Random range in pascal


ReBeL
09-28-2000, 03:23 PM
How can I set the random funciton to a range
let's say from 3 to 8
or from a to b
you get the point

gibben
09-29-2000, 02:28 PM
First find the range of the random values you want.
3 to 8 , 3 4 5 6 7 8 or max - min value so you have 6 possible values. Then calculate your offset which is 3 in this case. take the output of RANDOM(6) and add the offset of 3 to obtain a random value in the range of [3,8].

For A to Z you would use their decimal value equivilants 65 to 90 and use the same preceedure above.

- gibben