如何解决 7% 的问题,其中 6% 、 5% 效果很好

发布于 2024-10-08 21:18:07 字数 612 浏览 3 评论 0原文

案例 1(折扣 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

案例 2(折扣 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 

我在哪里应用此公式:

(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) ?

如何更正 7% 公式以获得精确的 1250.00 ?而不是分数错误。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小糖芽 2024-10-15 21:18:07

了解您从哪里获得原始公式以及您期望每个部分应该做什么确实很有帮助。事实上,我被迫做一些额外的跑腿工作,只是为了了解公式中的常数与示例中给出的成本有何关系。

您的处理成本似乎是根据以下公式计算的:

0.35 + (subtotal - discount) * 0.034

我不知道为什么存在 0.35。

您的折扣似乎是根据以下公式计算的:

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

总计似乎是根据以下公式计算的:

subtotal + handling costs - discount

写完此内容并进行更多思考后,我猜测您想要进行反向计算来确定小计,而只知道费率和小计。让我们从我们所知道的开始,然后根据需要重新排列公式。

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))

所以好消息是,我已经想出了与你相同的数学方程,现在大部分都明白你是如何得出这个方程的。坏消息是,在输入案例 2 的数字时,仍然存在百分之一的偏差。

这个小错误来自于我们实际上处理的是四舍五入的数字。最初计算手续费和折扣时,四舍五入到最接近的百位。这可以被视为舍入误差。当它们加在一起时,舍入误差会变大。这是处理百分比和价格时的正常副产品。

当进行反向计算时,起始数字(总计)包含舍入误差,最终数字(小计)可以预期接近预期值,但不能保证是原始小计。同样,这是由于舍入误差和最初计算总数时固有的不精确性造成的。

我自己的数学不足以预测和纠正公式中的舍入错误。不过,我确实有一个关于如何检测它并在事后纠正它的建议。计算出反向小计后,该数字可以用于进行正向计算。如果项目没有按应有的方式加起来,请应用“模糊因素”并重试。根据需要重复。它很混乱,而且不是特别优雅,但它应该可以工作。

希望这有帮助。

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.

淡淡的优雅 2024-10-15 21:18:07

我认为这只是浮点运算的 IEEE 标准。有一个工具可以显示实际发生的情况:

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文