title: Java negative BigInteger toString
body: <p>It seems I have a two's complement issue with Java's BigInteger. 
  I have a 64-bit integer where only the msb and the second msb are set to 1, the rest is 0. </p>
  
  <p>In decimal this comes up to: -4611686018427387904</p>
  
  <p>The Java side of my application receives this decimal number as a string, and converts it to BigInteger like so:</p>
  
  <pre><code>BigInteger bi = new BigInteger("-4611686018427387904", 10);
  </code></pre>
  
  <p>Then, it needs to display this number both in binary and hex forms.
  I tried to use:</p>
  
  <pre><code>String bin = bi.toString(2);
  String hex = bi.toString(16);
  </code></pre>
  
  <p>but I'm getting:</p>
  
  <pre><code>-100000000000000000000000000000000000000000000000000000000000000
  
  -4000000000000000
  </code></pre>
  
  <p>whereas I expect to get:</p>
  
  <pre><code>1100000000000000000000000000000000000000000000000000000000000000
  
  c000000000000000
  </code></pre>
  
  <p>Any tips?</p>