mathjs用法

JavaScript013

mathjs用法,第1张

import * as math from "mathjs"

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

专门为 JavaScript 和 Node.js 提供的一个广泛的数学库。支持数字,大数字(超出安全数的数字),复数,分数,单位和矩阵。 功能强大,易于使用。

官网: https://mathjs.org/docs/index.html

https://github.com/josdejong/mathjs

Math.js 支持三种类型的数字: