def isInBitRange(num, bits, signed):
    """
    Check if number is encodable in n-bits
    num     - number to check
    bits    - max number of bits
    signed  - 'S' = signed, 'U' = unsigned
    return: True if is in range
    """
    if signed == "S":
        return (2**(bits-1) > int(num) and -(2**(bits-1)) <= int(num))
    elif signed == "U":
        return 2**bits > int(num)
    else:
        raise ValueError("invalid signedness mark")