js-float-accuracy
v1.0.8
Published
js-float-accuracy
Downloads
19
Readme
install float-accuracy.js
npm install js-float-accuracy
use js-float-accuracy.js
node import
const accuracy=require('js-float-accuracy');
import accuracy from 'js-float-accuracy'
// division(除法)
console.log(accuracy.div(0.1,0.1)); // 1
// multiplication(乘法)
console.log(accuracy.mul(0.1,0.1)); // 0.01
// addition(加法)
console.log(accuracy.add(0.1,0.1)); // 0.2
// subtraction(减法)
console.log(accuracy.sub(0.1,0.1)); // 0
// 末位进1保留小数,第二个参数传入保留位数
console.log(accuracy.toCeil(0.01234, 4)); // 0.0124
// 末位舍掉保留小数,第二个参数传入保留位数
console.log(accuracy.toFloor(0.01235, 4)); // 0.0123
script label
<script src="~/js-float-accuracy/index.js">
// to do ...
// adopt window.accuracy use
</script>