code: public int readEliasGammaCodingPositiveInteger() throws IOException {
      int value;
      int counter = 0;
      int bit = readBit();
      while (bit == 0) {
        counter++;
        bit = readBit();
      }
      value = 1;
      for (int i = 0; i < counter; i++) {
        value = (2 * value) + readBit();
      }
      return value;
    }
docs: Read elias gamma coding positive integer.
  
  @return the int
  @throws IOException Signals that an I/O exception has occurred.