uniform rnd() results across the entire range?

Blitz3D Forums/Blitz3D Programming/uniform rnd() results across the entire range?

Pongo(Posted 2009) [#1]
Sorry if the subject isn't quite right,... not sure what to call this.

I would like to be able to get a roughly equal number of results on each of the numbers, however it appears that the bottom and top numbers of the range only get about half the hits of the other numbers. In the code below, the numbers 1-19 get around 1 million hits, while the numbers 0 and 20 get around 500k. This is consistent every time, so the question is,... how can I make all the numbers (roughly) even?




GfK(Posted 2009) [#2]
For generating random whole numbers, use Rand() instead of Rnd().

Using Rnd(), then converting to an int to put the result into an array, means that 0 and 20 will get less hits than 1-19 due to rounding.


Pongo(Posted 2009) [#3]
Ahh,... thanks.