def signed(n: int, size: int) -> int:
    """
    Convert an unsigned integer to a signed integer

    :param uint n: value to convert
    :param int size: byte width of n

    :return int: signed conversion
    """
    size *= 8
    if n >> (size - 1):  # Is the hi-bit set?
        return n - (1 << size)
    return n