def upper(x):
    """Returns the upper extreme of an uncertain quantity.
     This free function allows multiple uncertain quantity types to be supported
     in a generic way."""
    try:
        return x.upper
    except:
        try:
            return x.value + x.error
        except:
            return x
