def int_to_hex(number, bits=16):
    """Convert int to a four-character hex string.

    This uses two's complement in encoding the integer, per Huber's
    manual.
    """
    return '{:04X}'.format((number + (1 << bits)) % (1 << bits))
