title: How to implement an unsigned 64-bit int in Java using BigInteger class?
body: <p>I am looking for one datatype with exact capacity of 0 to 2^64 - 1. We know that Java as it is does not support 'unsigned' barring char datatype. </p>
  
  <p>There is BigInteger class that allows creation of larger numbers that long datatype cannot support. But I am not sure how BigInteger class would serve my purpose. BigInteger class allows assignment through constructors only. I see the following possibility but it generates a random number.</p>
  
  <pre><code>BigInteger(int numBits, Random rnd) 
  Constructs a randomly generated BigInteger, uniformly distributed over the range 0 to (2^numBits - 1), inclusive.
  </code></pre>
  
  <p>I can't see any setValue(x) kind of API that'd let me choose my own value to this BigInteger. How to implement this using BigInteger class or is there any other way of doing it? Please post code sample.</p>
  
  <p>PS: The question posted by someone <a href="https://stackoverflow.com/questions/508630/java-equivalent-of-unsigned-long-long">here</a> does not have implementation details.</p>