title: Random double between min and max
body: <pre><code>double get_random(double min, double max) {
    /* Returns a random double between min and max */
  
    return min * ((double) rand() / (double) RAND_MAX) - max;
  }
  </code></pre>
  
  <p>That's my function to generate random doubles between a min and a max. However, when I call <code>get_random(-1.0, 1.0);</code>, I get values between -2.0 and -1.0.</p>
  
  <p>Any idea of what I'm doing wrong and how I can fix it?</p>