title: Java8 unsigned arithmetic
body: <p>Java 8 is widely reported to have library support for unsigned integers. However, there seem to be no articles explaining how to use it and how much is possible.</p>
  
  <p>Some functions like Integer.CompareUnsigned are easy enough to find and seem to do what one would expect. However, I fail to write even a simple loop that loops over all powers of two within the range of unsigned long.</p>
  
  <pre><code>int i = 0;
  for(long l=1; (Long.compareUnsigned(l, Long.MAX_VALUE*2) &lt; 0) &amp;&amp; i&lt;100; l+=l) {
      System.out.println(l);
      i++;
  }
  </code></pre>
  
  <p>produces the output</p>
  
  <pre><code>1
  2
  4
  8
  ...
  1152921504606846976
  2305843009213693952
  4611686018427387904
  -9223372036854775808
  0
  0
  0
  ...
  0
  </code></pre>
  
  <p>Am I missing something or are external libraries still required for this simple task?</p>