def int_to_hex(num):
    """Convert an int to a hexadecimal string"""
    num = int(num)
    vals = { 10: 'a', 11: 'b', 12: 'c', 13: 'd', 14: 'e', 15: 'f'}
    if num < 0:
        sign = '-'
        num = -num
    else:
        sign = ''
    if num < 10:
        return sign + str(num)
    if num < 16:
        return sign + vals[num]

    return sign + int_to_hex(num / 16) + int_to_hex(num % 16)