[OCLUG-devel] Limiting range of random numbers

James Colannino james at colannino.org
Fri Nov 19 18:09:55 PST 2004


James Colannino wrote:

> Hey everyone,
>
> I'm using the following code snippet to generate suedo-random numbers[...]


Ok, well, after playing around a bit and trying a few random things, I 
think I managed to stumble across a possible solution.  If I return 
(number % 20) instead of just number, it seems to always give me a value 
between 0 and 19.  I'm not quite sure why this works (if someone could 
tell me how that would be great) but hey, at least it's working :)

James


More information about the OCLUG-devel mailing list