title: Python's random.uniform() in C++?
body: <p>I've been ripping my hair out for a while now with these random numbers in C++.</p>
  
  <p>In Python, I had the awesome:</p>
  
  <pre><code>random.uniform(0, 1)
  </code></pre>
  
  <p>Which churned out a new random number each time I called it.</p>
  
  <p>C++ <em>has</em> to have something like this. I Googled for a long time, and found <code>erand48()</code>, which I plan to implement into my raytracer (I'm translating it from Python to C++).</p>
  
  <p>I tried a simple test case, but I was hoping to create a <code>random_uniform()</code> function which always spits out a new random number (using <code>time()</code> isn't going to work AFAICT, as this will be running <em>really</em> quickly)</p>
  
  <pre><code>unsigned short Xi[3] = {0, 1, 27};
  std::cout &lt;&lt; erand48(Xi);
  </code></pre>
  
  <p>And the output was (and will be every time I call the program):</p>
  
  <pre><code>0.174529
  </code></pre>
  
  <p>I tried using the previous output as the new <code>Xi</code>, like this (<code>Xi</code>s initial value was defined):</p>
  
  <pre><code>float random_uniform() {
    long generated = erand48(Xi);
    int temp = generated * 1000000;
  
    unsigned short Xi[3] = {temp - 16, temp - 7, temp - 18};
  
    return generated;
  }
  </code></pre>
  
  <p>But that doesn't seem like it would generate random enough numbers (and it only spits out <code>0</code>. I', not sure why...).</p>
  
  <p>Is there any way that I could make a function which spits out a new random number each time?</p>