准确金额的分期付款

发布于 2024-12-20 11:00:27 字数 444 浏览 3 评论 0原文

有什么方法可以准确计算分期付款吗?还记得这些包裹的总和就是该包裹的总价值吗?我通常会做一个循环,它会在数据库中分裂和燃烧,如果包裹数量为4,我会记录四条记录..但我想知道是否有任何方法可以将最终总和准确的零碎部分,如X = 500,P = 3,如果我除(500 / 3)166.666将给出...但结果是我希望得到如下内容:X = 500, P = 3, p1 = 150: p2 = 150, p3 = 200

图例:X = 订单价值P = 数字地块。 , p1, p2, p3 = 地块 1, 2 和 3

请记住,订单的价值永远不会准确,我明白2598.902038.80 ..等。

is there any way to accurately calculate the installments? remembering that the sum of these parcels shall be the total value of the? I usually do a loop which will split and burn in the database, if the number of parcels is 4, I record four records .. but I want to know if there is any way that I can piecemeal parts that final sum is accurate, as X = 500, P = 3, if I dividor (500 / 3), 166.666 will give ... but the result is that I hope to get something like: X = 500, P = 3, p¹ = 150: p² = 150, p³ = 200

Legend: X = Order Value, P = Number of Parcels. , p¹, p², p³ = parcel 1, 2 and 3

Remember, the value of the order, will never be exact, I get 2598.90, 2038.80 .. etc.

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

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

发布评论

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

评论(1

苯莒 2024-12-27 11:00:27

如果我理解正确的话,这是我的猜测

$total = 23419.97;     // total amount
$total_parcel = 24;    // total parcel

// average parcle
$avg_parcel = floor($total / $total_parcel); // nearest integer;

// value for each parcel
$parcels = array_fill(0, $total_parcel, $avg_parcel);

// change last parcel value
// so, sum of all parcel = total
$parcels[$total_parcel-1] = $total-(($total_parcel-1)*$avg_parcel);

If I understand you correctly, here is my guess

$total = 23419.97;     // total amount
$total_parcel = 24;    // total parcel

// average parcle
$avg_parcel = floor($total / $total_parcel); // nearest integer;

// value for each parcel
$parcels = array_fill(0, $total_parcel, $avg_parcel);

// change last parcel value
// so, sum of all parcel = total
$parcels[$total_parcel-1] = $total-(($total_parcel-1)*$avg_parcel);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文