title: How to implement monotonically/sequentially increasing counter of 20 bytes in Java
body: <p>I need to implement sequentially increasing counter of fixed number of bytes (let us say 20 bytes) to represent a positive id.  I can use a byte array like </p>
  
  <pre><code>int size = 20;
  byte[] bytes = new byte[size]; //initializes to 0
  </code></pre>
  
  <p>But I donot understand how I can add 1 to least significant bit of bytes[0] where carry-on would go towards most significant bits. </p>
  
  <p>1) I reviewed <a href="https://stackoverflow.com/questions/32253298/adding-1-to-binary-byte-array">this</a> for addition, but that solution is adding to lowest byte and not bit</p>
  
  <p>2) java bytes are signed by default. But I am looking for positive counter, hence I need 20 bytes of unsigned bytes</p>