def getSignedVal(num: int, bitSize: int):
    """
    Return the signed value of the number.
    :param num: unsigned integer value
    :param bitSize: length of the value in bits
    """
    mask = (2 ** bitSize) - 1
    if num & (1 << (bitSize - 1)):
        return num | ~mask
    else:
        return num & mask