def int_max_value(bits, signed=True):
    """Returns the maximum int value of a signed or unsigned integer
    based on used bits.
    Arguments:
    bits -- How many bits, e.g., 16
    signed -- True if a signed int
    Returns:
    max_value -- The maximum int value based on given parameters
    """
    if signed:
        max_value = pow(2, bits - 1) - 1
    else:
        max_value = pow(2, bits) - 1
    return max_value