bignumber.js是一款用于任意精度十进制和非十进制算术的JavaScript库
作者:互联网
安装
npm install bignumber.js
引入
import { BigNumber } from 'bignumber.js'
实例方法
加法:plus
0.1 + 0.2 // 0.30000000000000004 x = BigNumber(0.1) y = x.plus(0.2) // '0.3'
减法:minus
0.3 - 0.1 // 0.19999999999999998 x = BigNumber(0.3) x.minus(0.1) // '0.2'
乘法:multipliedBy
0.6 * 3 // 1.7999999999999998 x = BigNumber(0.6) y = x.multipliedBy(3) // '1.8'
标签:bignumber,BigNumber,0.2,0.1,0.3,JavaScript,js,十进制 来源: https://www.cnblogs.com/adbg/p/12091457.html