read a binary int value
188939
def read_binary_int(fname,fd,length)
      if length > 4
        raise CFFormatError.new("Integer greater than 16 bytes: #{length}")
      end

      nbytes = 1 << length

      buff = fd.read(nbytes)

      CFInteger.new(
        case length
        when 0 then buff.unpack("C")[0]
        when 1 then buff.unpack("n")[0]
        when 2 then buff.unpack("N")[0]
        # 8 byte integers are always signed
        when 3 then buff.unpack("q>")[0]
        # 16 byte integers are used to represent unsigned 8 byte integers
        # where the unsigned value is stored in the lower 8 bytes and the
        # upper 8 bytes are unused.
        when 4 then buff.unpack("Q>Q>")[1]
        end
      )
    end
1179891
def readinto(self, b):
        """"""
        data = self.read(len(b))
        if not data:
            return 0
        b[:len(data)] = data
        return len(data)
296350
@Override
  public int read(byte[] b, int off, int len) throws IOException {
    int bytes = inner.read(b, off, Math.min(len, remaining));
    if (bytes > 0) {
      remaining -= bytes;
    }
    return bytes;
  }
1082515
private int readInt() {
    String tag = readWord();
    try {
      int radix = 10;
      if (tag.startsWith("0x") || tag.startsWith("0X")) {
        tag = tag.substring("0x".length());
        radix = 16;
      }
      return Integer.valueOf(tag, radix);
    } catch (Exception e) {
      throw unexpected("expected an integer but was " + tag);
    }
  }
507668
def read_bit_as_binary(bitlen)
      unless bit_pointer % 8 == 0
        raise BinaryException.new("Bit pointer must be pointing start of byte. " +
                                  "But now pointing #{bit_pointer}.")
      end
      unless bitlen % 8 == 0
        raise BinaryException.new("Arg must be integer of multiple of 8. " +
                                  "But you specified #{bitlen}.")
      end
      if self.length - bit_pointer/8 < bitlen/8
        raise BinaryException.new("Rest of self length(#{self.length - bit_pointer/8}byte)" +
                                  " is shorter than specified byte length(#{bitlen/8}byte).")
      end
      response = self[bit_pointer/8, bitlen/8]
      bit_pointer_inc(bitlen)
      return response
    end
611808
public static int readInt(byte b[], int offset) {
    int retValue;

    retValue = ((int)b[offset++]) << 24;
    retValue |= ((int)b[offset++] & 0xff) << 16;
    retValue |= ((int)b[offset++] & 0xff) << 8;
    retValue |= (int)b[offset] & 0xff;

    return retValue;
  }
1248654
public static int readInt(byte[] source, int position) {
        return (source[position] & 0xFF) << 24
                | (source[position + 1] & 0xFF) << 16
                | (source[position + 2] & 0xFF) << 8
                | (source[position + 3] & 0xFF);
    }
346525
public static long readUnsignedInt(byte[] bytes, int offset) {
        return (((bytes[offset + 0] & 0xffL) << 24) | ((bytes[offset + 1] & 0xffL) << 16)
                | ((bytes[offset + 2] & 0xffL) << 8) | (bytes[offset + 3] & 0xffL));
    }
940227
public int readInt()
    throws IOException
  {
    if (_readOffset + 4 < _readLength) {
      return (((_readBuffer[_readOffset++] & 0xff) << 24)
              + ((_readBuffer[_readOffset++] & 0xff) << 16)
              + ((_readBuffer[_readOffset++] & 0xff) << 8)
              + ((_readBuffer[_readOffset++] & 0xff)));
    }
    else {
      return ((read() << 24)
              + (read() << 16)
              + (read() << 8)
              + (read()));
    }
  }
274025
def _read_offset_value(self, f, offset, size):
        '''
        
        '''
        f.seek(offset, 0)
        if (size == 8):
            return int.from_bytes(f.read(8), 'big', signed=True)
        else:
            return int.from_bytes(f.read(4), 'big', signed=True)
445253
public static int fromBinary(boolean[] binary)
    {
        Check.notNull(binary);

        int number = 0;
        for (final boolean current : binary)
        {
            number = number << 1 | boolToInt(current);
        }
        return number;
    }
947151
def int_to_binary(value)
      # Note: nbytes is actually an exponent.  number of bytes = 2**nbytes.
      nbytes = 0
      nbytes = 1  if value > 0xFF # 1 byte unsigned integer
      nbytes += 1 if value > 0xFFFF # 4 byte unsigned integer
      nbytes += 1 if value > 0xFFFFFFFF # 8 byte unsigned integer
      nbytes += 1 if value > 0x7FFFFFFFFFFFFFFF # 8 byte unsigned integer, stored in lower half of 16 bytes
      nbytes = 3  if value < 0 # signed integers always stored in 8 bytes

      Binary.type_bytes(0b0001, nbytes) <<
        if nbytes < 4
          [value].pack(["C", "n", "N", "q>"][nbytes])
        else # nbytes == 4
          [0,value].pack("Q>Q>")
        end
    end
386268
def read_uint(data, start, length):
    """"""
    return int.from_bytes(data[start:start+length], byteorder='big')
1001499
def read_byte_as_integer(bytelen)
      unless bit_pointer % 8 == 0
        raise BinaryException.new("Bit pointer must be pointing start of byte. " +
                                  "But now pointing #{bit_pointer}.")
      end
      if self.length - bit_pointer/8 < bytelen
        raise BinaryException.new("Rest of self length(#{self.length - bit_pointer/8}byte) " + 
                                  "is shorter than specified byte length(#{bytelen}byte).")
      end
      response = 0
      bytelen.times do |i|
        response = response << 8
        response += to_i(bit_pointer/8 + i)
      end
      bit_pointer_inc(bytelen * 8)
      return response
    end
276968
def binary_value_or_stdin(value):
    
    if value is None:
        reader = io.open(sys.stdin.fileno(), mode='rb', closefd=False)
        return reader.read()
    elif six.PY3:
        return os.fsencode(value)
    else:
        return value
549872
def decode_int(v):
    """"""
    if len(v) > 0 and (v[0] == b'\x00' or v[0] == 0):
        raise Exception("No leading zero bytes allowed for integers")
    return big_endian_to_int(v)
550691
def read_plain_int96(file_obj, count):
    """"""
    items = struct.unpack(b"<" + b"qi" * count, file_obj.read(12 * count))
    return [q << 32 | i for (q, i) in zip(items[0::2], items[1::2])]