我正在尝试根据每个积分的金额进行一些计算,以获得所请求金额中使用的总积分。
请参考以下代码:
<?php
$amount_perpoints = bcdiv(622.9106666666667,1,2); // AMOUNT OF MONEY PER POINTS
$request_amount = 3114.55; //REQUESTED AMOUNT OF POINTS
$points = 0; // THIS WILL CONTAIN THE TOTAL POINTS
$total_amount = 0; // THIS WILL INCREMENT ACCORDING TO THE PRODUCT OF THE CURRENT POINT AND AMOUNT PER POINTS
while($total_amount < $request_amount){
$points = $points+0.50; //POINTS INCREMENTING BY 0.5
$total_amount = $points * $amount_perpoints;
}
echo $points;
?>
输出:5.50
上面的场景输出,但我相信它应该只是.在迭代的点,并且 已经具有相同的值。为什么 while 循环仍然满足比较变量的两个值不小于但等于?5.505.005.00$total_amount$request_amount3114.55
一只萌萌小番薯
慕神8447489
德玛西亚99
侃侃无极