title: Generating a uniform random integer in C++
body: <p>The problem is that I need to generate a random integer between 0 and 999 (for investigation of a mathematical conjecture). All of the values need to have the same probability of coming up.</p>
  
  <p>I have tried <code>rand()</code>, but with <code>RAND_MAX</code> being 32767 (on my compiler) this means that just taking <code>rand() % 1000</code> leads to the first 1–767 being significantly more likely to come up (and that's assuming that all possibilities have the same probability in <code>rand()</code> in the first place).</p>
  
  <p>I'm using Windows so <code>/dev/random</code> isn't an option.</p>