How would you make a function that generates a random number from 1 to 25 million?
I've thought about using rand()
but am I right in thinking that the maximum number, RAND_MAX
is = 32000 (there about)?
Is there a way around this, a way that doesn't reduce the probability of picking very low numbers and doesn't increase the probability of picking high / medium numbers?
Edit: @Jamey D 's method worked perfectly independent of Qt.
Have a look at ran3
http://www.codeforge.com/read/33054/ran3.cpp__html
You should be able to get what you want from it.
Ran3 is (atleast when I was still doing computational modelling) faster than rand() with a more uniform distribution, though that was several years ago. It returns a random integer value.
For example, getting the source code from the link above:
You could (should) use the new C++11
std::uniform_real_distribution