Return next 56-bit unsigned int from buffer. (little-endian)
169041
public final long getUlong56() {
        if (position + 6 >= origin + limit) throw new IllegalArgumentException("limit excceed: "
                                                                               + (position - origin + 6));

        byte[] buf = buffer;
        return ((long) (0xff & buf[position++])) | ((long) (0xff & buf[position++]) << 8)
               | ((long) (0xff & buf[position++]) << 16) | ((long) (0xff & buf[position++]) << 24)
               | ((long) (0xff & buf[position++]) << 32) | ((long) (0xff & buf[position++]) << 40)
               | ((long) (0xff & buf[position++]) << 48);
    }
311953
def write_int8(self, value, little_endian=True):
        
        if little_endian:
            endian = "<"
        else:
            endian = ">"
        return self.pack('%sb' % endian, value)
1160435
def read_uint16(self, little_endian=True):
        
        if little_endian:
            endian = "<"
        else:
            endian = ">"
        return self.unpack('%sH' % endian, 2)
1317998
def read_uint64(self, little_endian=True):
        
        if little_endian:
            endian = "<"
        else:
            endian = ">"
        return self.unpack('%sQ' % endian, 8)
1257903
private int nextSetBit(int fromIndex) {
      if (fromIndex < 0)
         throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex);

      int u = intIndex(fromIndex);
      int arrayLength = array.length();
      if (u >= arrayLength)
         return -1;

      int possible = array.get(u) & (INT_MASK << fromIndex);

      while (true) {
         if (possible != 0) {
            return (u << ADDRESS_BITS_PER_INT) + Integer.numberOfTrailingZeros(possible);
         }
         if (++u == arrayLength) {
            return -1;
         }
         possible = array.get(u);
      }
   }
883124
public int hgetbits(int N)
   {
   	 totbit += N;
	 
	 int val = 0;
	 
	 int pos = buf_byte_idx;
	 if (pos+N < BUFSIZE)
	 {
		while (N-- > 0)
		{
			val <<= 1;
			val |= ((buf[pos++]!=0) ? 1 : 0);		 
		}
	}
	 else
	 {	 
		 while (N-- > 0)
		{
			 val <<= 1;			 
			 val |= ((buf[pos]!=0) ? 1 : 0);
			 pos = (pos+1) & BUFSIZE_MASK;
		}		 
	 }	
	 buf_byte_idx = pos;
	 return val;
   }
895675
function (num) {
  var arr = [];

  if (num === 0) return new Buffer([0]);

  // Break up num into groups of 7-bit values
  while (num) {
    arr.unshift(num & (127));
    num >>= 7;
  }

  // Flip MSB of all 7-bit values except the last one
  arr = _.map(_.initial(arr), function (val, i) {
    return val + 128;
  }).concat(_.last(arr));

  return new Buffer(arr);
}
1099914
def b58encode(b, errors='strict'):
    ""
    len_ = len(b)

    # Convert big-endian bytes to integer
    n = BigInteger.deserialize(BytesIO(b), len_)

    # Divide that integer into base58
    res = []
    while n > 0:
        n, r = divmod (n, 58)
        res.append(b58digits[r])
    res = ''.join(res[::-1])

    # Encode leading zeros as base58 zeros
    pad = 0
    for c in b:
        if c == six.int2byte(0): pad += 1
        else: break
    return (b58digits[0] * pad + res, len_)
1331529
function uint6ToB64 (nUint6) {

  return nUint6 < 26 ?
      nUint6 + 65
    : nUint6 < 52 ?
      nUint6 + 71
    : nUint6 < 62 ?
      nUint6 - 4
    : nUint6 === 62 ?
      43
    : nUint6 === 63 ?
      47
    :
      65;

}
795367
def read_int64(self, little_endian=True):
        
        if little_endian:
            endian = "<"
        else:
            endian = ">"
        return self.unpack('%sq' % endian, 8)
235482
def next_bit_address(self):
        """"""
        if self._current_bit_address == "":
            if self._is_16bit:
                return "{0}.{1}".format(
                    self.next_address(),
                    "00")
            return "{0}.{1}".format(
                self.next_address(),
                "0")
        if self._is_16bit:
            bool_half = int(self._current_bit_address.split(".")[1])
            if bool_half < 4:
                register_half = self._current_bit_address.split(".")[0]
                return "{0}.{1}".format(
                    register_half,
                    pad_zeroes(str(bool_half + 1), 2))
            self.move_to_next_address(self._size_of_current_register_address)
            return "{0}.{1}".format(
                self.next_address(),
                "00")
        bool_half = int(self._current_bit_address.split(".")[1])
        if bool_half < 3:
            register_half = self._current_bit_address.split(".")[0]
            return "{0}.{1}".format(
                register_half,
                bool_half + 1)
        self.move_to_next_address(self._size_of_current_register_address)
        return "{0}.{1}".format(
            self.next_address(),
            "0")
304648
def _endian(self) -> str:
        '''
        
        '''
        if (self._encoding == 1 or self._encoding == 2 or self._encoding == 5 or
            self._encoding == 7 or self._encoding == 9 or self._encoding == 11 or
                self._encoding == 12):
            return 'big-endian'
        else:
            return 'little-endian'
70161
public static int readMediumInt(IoBuffer in) {
        final byte a = in.get();
        final byte b = in.get();
        final byte c = in.get();
        // Fix unsigned values
        int val = 0;
        val += (a & 0xff) << 16;
        val += (b & 0xff) << 8;
        val += (c & 0xff);
        return val;
    }
203477
function read_bits_n(buf, bl, n) {
	var w = (bl&7), h = (bl>>>3), f = ((1<<n)-1);
	var v = buf[h] >>> w;
	if(n < 8 - w) return v & f;
	v |= buf[h+1]<<(8-w);
	if(n < 16 - w) return v & f;
	v |= buf[h+2]<<(16-w);
	if(n < 24 - w) return v & f;
	v |= buf[h+3]<<(24-w);
	return v & f;
}
619811
function readUInt64BE(buffer, start) {
  var data = buffer.slice(start, start + 8);
  return data.readUInt32BE(4, 8);
}
755907
def read_int(self):
		
		if self.reader.sysinfo.ProcessorArchitecture == PROCESSOR_ARCHITECTURE.AMD64:
			return int.from_bytes(self.read(8), byteorder = 'little', signed = True)
		else:
			return int.from_bytes(self.read(4), byteorder = 'little', signed = True)
278707
private int extractNextTlvElementLength(IoBuffer in) {
        if (!hasRemainingData(in, 2)) {
            return NOT_ENOUGH_DATA;
        }
        try {
            in.mark();
            int firstByte = in.getUnsigned();
            boolean tlv8 = (firstByte & TLV16_MASK) == 0;
            if (tlv8) {
                // 8 bit length. NB! Reads one unsigned byte as an integer
                return in.getUnsigned() + TLV8_HEADER_LENGTH;
            }
            // skip tlv16 LSB byte
            in.skip(1);
            if (!hasRemainingData(in, 2)) {
                return NOT_ENOUGH_DATA;
            }
            // 16 bit length. NB! Reads two bytes unsigned integer
            return in.getUnsignedShort() + TLV16_HEADER_LENGTH;
        } finally {
            in.reset();
        }
    }