您现在的位置是: 首页 > PHP PHP
固定费率N次后费率及本金(复利率)
冬寂 2021-12-22 10:12:21 【PHP】 4087人已围观
$cash = 1000;$i=0;while(1 == bccomp($cash,10,5)){ $tax = bcmul($cash,0.001,5); $cash = bcsub($cash,$tax,5); $i++; echo "当前执行第{$i}次,本次手续费{$tax},剩余金额{$cash}"."<br>";}echo $i;echo '<hr>';getTax(1000,0.001,3006,5);//本金,费率,第N次,精度function getTax($benjin,$feilv,$cishu,$jingdu){ //公式:1000*(1-0.001)^n $a = bcpow(1-$feilv, $cishu, $jingdu); $b = bcmul($benjin,$a,$jingdu); echo "当前执行第{$cishu}次,本次手续费{$a},剩余金额{$b}"."<br>";}
下一篇: PHP高精度计算函数