title: Strange Behavior when printing "all powers of 2 that fit in a long"
body: <p>I'm attempting to print all powers of two from 2^0 onward that will fit into a long variable.</p>
  
  <p>This is my code so far</p>
  
  <pre><code>    long y = 0;
      int iteration = 1;
      for (y = 1; y &lt; 9223372036854775807L; y *= 2) {
  
          System.out.println("2 to the power of " + iteration + " is " +y);
          iteration++;
  </code></pre>
  
  <p>This behaves as expected until 2^63 when the console prints</p>
  
  <pre><code>2 to the power of 62 is 4611686018427387904
  2 to the power of 63 is -9223372036854775808
  2 to the power of 64 is 0
  </code></pre>
  
  <p>Then the program continually returns</p>
  
  <pre><code>2 to the power of 64 is 0
  2 to the power of 65 is 0
  2 to the power of 66 is 0
  </code></pre>
  
  <p>And so on.</p>
  
  <p>What is happening here?</p>