math.js 使用

math.js  使用解决 js  精度计算问题。

 

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());

 以上demo  只为记忆,仅供参考。具体可以查看 https://mathjs.org/ 官网

posted @ 2019-10-17 19:34  我喜欢喝糖水  阅读(10322)  评论(1编辑  收藏  举报
我喜欢喝糖水的博客友链:股票指标编程学习