def format_fields(fields):
    """
    :param fields: list of numbers and operations as strings
    :return a list of formatted fields, with numbers cast into integers
    """
    leading_sign = ''
    formatted_fields = []
    for field in fields:
        try:
            result = int(leading_sign + field)
        except ValueError:
            leading_sign = ''
            if len(field) == 1:
                result = field
            elif len(field) == 2:
                if field == '**':
                    result = field
                elif field[1] in '+-':
                    result, leading_sign = field
                else:
                    raise Exception('Invalid operation')
            elif len(field) == 3:
                if field[:2] == '**':
                    if field[2] in '+-':
                        result, leading_sign = field[:2], field[2]
            else:
                raise Exception('Unsupported operation')
        formatted_fields.append(result)
    return formatted_fields
