Question

Case 1 (discount 6%):

Subtotal:   750.00
Discount:   45.00
Handling cost:  24.32
21% VAT:    0.00
Total (this is the amount you will deposit):    729.32

Case 2 (discount 7%):

Subtotal:   1250.00
Discount:   87.50
Handling cost:  39.88
21% VAT:    0.00
Total (this is the amount you will deposit):    1202.38 

Where i am applying this formula:

(729.32  - 0.35) / 1.034/ 0.94   =  750.00    (<<--- CORRECT ) ?

(1202.38 - 0.35) / 1.034/ 0.93   = 1250.01    (<<--- My problem why not 1250.00) ?

How to correct the 7% formula to get exactly 1250.00 ? Instead of fraction error.

Was it helpful?

Solution

It would really help to know where you got your original formula, and what you expect each part is supposed to do. As it is, I was forced to do some extra leg-work just to understand how the constants in your formula relate to the costs given in your example.

Your handling costs appears to be calculated from the formula:

0.35 + (subtotal - discount) * 0.034

I do not know why the 0.35 exists.

Your discount appears to be calculated from the formula:

subtotal * discount rate, (where discount rate has already been converted to a decimal)

The total appears to be calculated from the formula:

subtotal + handling costs - discount

After writing this, and some more thinking, I am going to guess that you want to do a reverse calculation to determine the subtotal, when only knowing the rates and the subtotal. Let's start out with what we know, and then rearrange the formula as necessary.

subtotal = total + discount - handling costs
subtotal = total + subtotal * discount rate -  (0.35 + (subtotal - discount) * 0.034)
subtotal (1 - discount rate) = total - (0.35 + subtotal - subtotal * discount rate) * 0.034
subtotal (1 - discount rate) = total - 0.35 - subtotal (1 - discount rate) * 0.034
subtotal (1 - discount rate) + subtotal (1 - discount rate) * 0.034 = total - 0.35
subtotal (1 - discount rate) (1 + 0.034) = total - 0.35
subtotal (1 - discount rate) * 1.034) = total - 0.35
subtotal = (total - 0.35) / ((1 - discount rate) * (1.034))

So the good news is that I have come up with the same mathematical equation as you, and now understand for the most part how you arrived at it. The bad news is that there is still the off-by-one one hundredth when punching in the numbers for case #2.

This small error comes from the fact that we are in fact dealing with rounded numbers. When the handling cost and discount are originally calculated, they get rounded to the nearest hundredth. This can be considered as a rounding error. When they get added together, the rounding error becomes larger. This is a normal byproduct when dealing with percentages and prices.

When the reverse calculation is done, the starting number (total) contains the rounding error and the final number (subtotal) can be expected to be close to the expected value, but is not guaranteed to be the original subtotal. Again, this is due to the rounding errors and inherent imprecision in how the total was first calculated.

My own math is not good enough to predict and correct for the rounding errors in formula. However, I do have a suggestion in how to detect it and correct it after the fact. After calculating the reverse sub-total, that number can be used to do a a forward calculation. Should items not add up as they should, apply a "fudge factor" and try again. Repeat as necessary. It's messy, and not particularly elegant, but it should work.

Hope this helps.

OTHER TIPS

I think it's just the IEEE-Standard for floating-point operations. There's a tool to display, what actally happens:

http://www.h-schmidt.net/FloatApplet/IEEE754.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top