jsfloatcal
v1.0.3
Published
简易javascript 浮点数精度计算,包含加、减、乘、除运算
Downloads
17
Readme
jsfloatcal
快速上手
安装
npm i jsfloatcal
使用
import { add, subtract, multiply, divide } from 'jsfloatcal'
例子
// 加
function add(a, b, digits) {
return operation(a, b, digits, 'add')
}
// 减
function subtract(a, b, digits) {
return operation(a, b, digits, 'subtract')
}
// 乘
function multiply(a, b, digits) {
return operation(a, b, digits, 'multiply')
}
// 除
function divide(a, b, digits) {
return operation(a, b, digits, 'divide')
}
add(0.1,0.2) //0.3
add(0.1,0.2,2) //0.30
注:digits 为精确的位数 默认为0,可不传