title: Random floating point double in Inclusive Range
body: <p>We can easily get random floating point numbers within a desired range <code>[X,Y)</code> (note that X is inclusive and Y is exclusive) with the function listed below since <code>Math.random()</code> (and most pseudorandom number generators, AFAIK) produce numbers in <code>[0,1)</code>:</p>
  
  <pre class="lang-javascript prettyprint-override"><code>function randomInRange(min, max) {
    return Math.random() * (max-min) + min;
  }
  // Notice that we can get "min" exactly but never "max".
  </code></pre>
  
  <p>How can we get a random number in a desired range <em>inclusive</em> to both bounds, i.e. <code>[X,Y]</code>?</p>
  
  <p>I suppose we could "increment" our value from <code>Math.random()</code> (or equivalent) by "rolling" the bits of an <a href="http://en.wikipedia.org/wiki/IEEE_754-2008" rel="noreferrer">IEE-754 floating point double precision</a> to put the maximum possible value at 1.0 exactly but that seems like a pain to get right, especially in languages poorly suited for bit manipulation.  Is there an easier way?</p>
  
  <p>(As an aside, why do random number generators produce numbers in <code>[0,1)</code> instead of <code>[0,1]</code>?)</p>
  
  <p><strong>[Edit]</strong> Please note that I have no <em>need</em> for this and I am fully aware that the distinction is pedantic.  Just being curious and hoping for some interesting answers.  Feel free to vote to close if this question is inappropriate.</p>