def int_bounds(signed, bits):
    """
    calculate the bounds on an integer type
    ex. int_bounds(8, True) -> (-128, 127)
        int_bounds(8, False) -> (0, 255)
    """
    if signed:
        return -(2 ** (bits - 1)), (2 ** (bits - 1)) - 1
    return 0, (2 ** bits) - 1