Below is a function to round to nearest .05. The round function simply rounds up or down to the nearest first decimal place. Example 2.26 rounds to 2.3
round_to_nearst_05 = round($amount * 2, 1) / 2
The function below will round to the nearest .05. For example 2.28 will round to 2.3
My question involves calculating the change. Will the following be ALWAYS be equal (it seems to work in this case):
Let x = 3 (amount tendered)
Let y = 2.28 (sale total)
change calc 1 = X - round_to_nearst_05(Y)
change calc 2 = round_to_nearest_05(X-Y)