分类目录: html5
math.js的加减乘除
Post date:
Author: cyy
标签: math.js
Number of comments: no comments
math.js
引用js
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js" type="text/javascript"></script>
或者
npm install mathjs
加减乘除demo
// 0.1+0.2
math.format(math.chain(math.bignumber(0.1)).add(math.bignumber(0.2)).done());
// 0.2-0.1
math.format(math.chain(math.bignumber(0.2)).subtract(math.bignumber(0.1)).done());
// 0.1*0.2
math.format(math.chain(math.bignumber(0.1)).multiply(math.bignumber(0.2)).done());
// 0.1/0.2
math.format(math.chain(math.bignumber(0.1)).divide(math.bignumber(0.2)).done());
参考自:https://www.cnblogs.com/wxhhts/p/11694306.html
代码只是方便up主记忆,仅供参考~~