module BinData::Int

def pack_directive(nbits, endian, signed)

def pack_directive(nbits, endian, signed)
  bits_per_word = bytes_per_word(nbits) * 8
  nwords        = nbits / bits_per_word
  if (nbits % 64).zero?
    d = (endian == :big) ? 'Q>' : 'Q<'
  elsif (nbits % 32).zero?
    d = (endian == :big) ? 'L>' : 'L<'
  elsif (nbits % 16).zero?
    d = (endian == :big) ? 'S>' : 'S<'
  else
    d = 'C'
  end
  if pack_directive_signed?(nbits, signed)
    (d * nwords).downcase
  else
    d * nwords
  end
end