php中的高精度浮点计算钱金额用什么函数?
浮点直接加减乘数老是出问题
网友回复
<?php
/**
* 精确加法
* @param [type] $a [description]
* @param [type] $b [description]
*/
function math_add($a,$b,$scale = '2') {
return bcadd($a,$b,$scale);
}
/**
* 精确减法
* @param [type] $a [description]
* @param [type] $b [description]
*/
function math_sub($a,$b,$scale = '2') {
return bcsub($a,$b,$scale);
}
/**
* 精确乘法
* @param [type] $a [description]
* @param [type] $b [description]
*/
function math_mul($a,$b,$scale = '2') {
return bcmul($a,$b,$scale);
}
/**
* 精确除法
* @param [type] $a [description]
* @param [type] $b [description]
...点击查看剩余70%


