import decimal


def equal_within_tolerance(val1, val2, decimals=None):
    """Returns true if va1 is equal to val2 within given tolerance."""
    # The rule allows a tolerance for rounding between the values tested of 2 based on the scale of the values. For example, if the values are reported in millions, the rounding tolerance would be $2 million.
    if decimals is None:
        return val1 == val2
    return abs(val1-val2) <= decimal.Decimal(2).scaleb(-decimals)