title: Can Random.nextDouble() ever return the inclusive value?
body: <p>I was playing around with the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Random.html#nextDouble" rel="nofollow"><code>Random</code> class's <code>nextDouble()</code></a> method as shown below. I expected <code>nextDouble()</code> to return a pseudorandom <code>double</code> value on the interval [-50.0, 50.0), however, after running the loop 1 billion times the output came out to <code>maximum: 49.99999995014588 minimum: -49.99999991024878</code>. I ran the loop without my manipulations of the output interval, and I got <code>maximum: 0.9999999998979311 minimum: 0.0</code>. I find this strange, because all I have done to the <code>0.0</code> that was returned is multiply it by 100.0 and subtract 50.0 from it. Why does this code snippet below never return exactly -50.0?</p>
  
  <p>EDIT: Just for fun I ran the loop another 500 million times, and the output is now: <code>maximum: 49.99999994222232 minimum: -49.999999996750944</code>.</p>
  
  <pre><code>import java.util.Random;
  
  public class randomTest{
  
  public static void main(String[] args) {
  
      double max = 0;
      double min = 0;
      Random math = new Random();
      for(int a = 0; a &lt; 1000000000; a++) {
          double rand = math.nextDouble() * 100.0 - (100.0 / 2.0);
          max = Math.max(max, rand);
          min = Math.min(min, rand);
      }
      System.out.println("maximum: " + max + " minimum: " + min);
  }
  }
  </code></pre>