Rick wrote: > I must say that I like your random generator much better than mine. Thanks :-) > Avoids the repeat loop and potential problems there. I don't > follow what you meant by "If you need to include both bounds in > the range of values, use random(30000) instead of random(30000)-1." > Do you mean that if I want to sometimes actually get the preset > gupper as a value I use "random(3000)"? That's one way of doing it. > function myRandom lower,upper > return trunc((random(30000)-1)/30000 * (upper - lower)) + lower > -- returns a whole number R, lower <= R < upper > end myRandom The way this function is written, myRandom(5,10) will only ever return values 5, 6, 7, 8, or 9, but never 10. So, if you want to occassionally return the upper limit, you can either call myRandom(glower, gupper + 1), or you can modify the algorithm so that it doesn't subtract one from the random value. That is, it uses: trunc(random(30000)/30000 * (upper - lower)) + lower Note if you call the function with a lower limit GREATER than the upper limit (eg myRandom(25,1)) the results might not be what you expect. -- Steven D'Aprano ========================================== M.B. Sales Pty Ltd Ph: +61 3 9460-5244 A.C.N. 005-964-796 Fax: +61 3 9462-1161 Archives: http://www.mail-archive.com/metacard%40lists.best.com/ Info: http://www.xworlds.com/metacard/mailinglist.htm Please send bug reports to <[EMAIL PROTECTED]>, not this list.