title: Get random double (floating point) value from random byte array between 0 and 1 in C#?
body: <p>Assume I have an array of bytes which are truly random (e.g. captured from an entropy source). </p>
  
  <pre><code>byte[] myTrulyRandomBytes = MyEntropyHardwareEngine.GetBytes(8);
  </code></pre>
  
  <p>Now, I want to get a random double precision floating point value, but <strong>between the values of 0 and positive 1</strong> (like the <code>Random.NextDouble()</code> function performs).</p>
  
  <p>Simply passing an array of 8 random bytes into <code>BitConverter.ToDouble()</code> can yield strange results, but most importantly, the results will almost never be less than 1. </p>
  
  <p>I am fine with bit-manipulation, but the formatting of floating point numbers has always been mysterious to me. I tried many combinations of bits to apply randomness to and always ended up finding the numbers were either just over 1, always VERY close to 0, or very large.</p>
  
  <p>Can someone explain which bits should be made random in a <code>double</code> in order to make it random within the range 0 and 1?</p>