php calculate float

后端 未结 3 972
挽巷
挽巷 2021-01-14 12:23

I have a weird math calculation here. I hope someone will explain.

$a = 1.85/100;
$b = 1.5/100;
$c = 1.1/100;
$d = 0.4/100;
$e = 0.4/100;
$f = 0.4/100;
$g =         


        
3条回答
  •  深忆病人
    2021-01-14 13:04

    There is nothing wrong going there, there are simply rounding approximation.

    In this very cas you should multiply all your values for 1000 and do a division at the end of the calculation or, better, resort to precise calculation extension

提交回复
热议问题