def absolute_or_percentage_within(string, low, high):
    """
    Parse a string giving a value as either an absolute float value or a
    percentage. Throws a ValueError when outside the stated range.
    """
    string = string.strip()
    if string.endswith('%'):
        perc = float(string.rstrip('%')) / 100.0
        value = low + (high - low) * perc
    else:
        value = float(string)
    if not low <= value <= high:
        raise ValueError('Value must be between {} and {}'.format(low, high))
    return value
