class CFPropertyList::Binary

def int_to_binary(value)

Codes an integer to binary format
def int_to_binary(value)
  nbytes = 0
  nbytes = 1  if value > 0xFF # 1 byte integer
  nbytes += 1 if value > 0xFFFF # 4 byte integer
  nbytes += 1 if value > 0xFFFFFFFF # 8 byte integer
  nbytes = 3  if value < 0 # 8 byte integer, since signed
  Binary.type_bytes(0b0001, nbytes) <<
    if nbytes < 3
      [value].pack(
        if nbytes == 0    then "C"
        elsif nbytes == 1 then "n"
        else "N"
        end
      )
    else
      # 64 bit signed integer; we need the higher and the lower 32 bit of the value
      high_word = value >> 32
      low_word = value & 0xFFFFFFFF
      [high_word,low_word].pack("NN")
    end
end