He wants to exclude those random numbers that are not of a certain length

Example: Random number with 3 to 4 digits between -10000 and 10000 would exclude those numbers that are only two digits (like -12 or 98)

11-14-2012, 10:34 AM

minder

yep you're right - deleted my post

11-14-2012, 10:46 AM

felgall

There's no need for a loop. The following code does it with only one call to Math.random as the number returned always maps to within the required range with the same distribution regardless of what numbers are entered.