Big.js
GitHub文档
安装
npm install Big.js
引入
import Big from 'big.js';
USE
let x = new Big(0.3);
console.log(+x.plus(0.1))
`使用时前面要用 +/Number() 转换为Number类型,不然 打印出来的是Big对象`
let x = new Big(0.3);
console.log(Number(x.minus(0.1));
`使用时前面要用 +/Number() 转换为Number类型,不然 打印出来的是Big对象`
let x = new Big(0.3);
console.log(+x.times(0.1));
`使用时前面要用 +/Number() 转换为Number类型,不然 打印出来的是Big对象`
let x = new Big(12);
console.log(+x.minus(2));
`使用时前面要用 +/Number() 转换为Number类型,不然 打印出来的是Big对象`
let x = new Big(-3);
console.log(Number(x.abs()));
`使用时前面要用 +/Number() 转换为Number类型,不然 打印出来的是Big对象`
let x = new Big(1);
console.log(Number(x.mod(0.9)));
`使用时前面要用 +/Number() 转换为Number类型,不然 打印出来的是Big对象`