BigInt based BigDecimal(arbitrary precision floats) implementation for Node.js. This implementation is based on java BigDecimal class. Like java BigDecimal class, it uses big integers internally. This implementation is faster than popular big decimal libraries. See benchmarks section for comparison.
Note: This release is a preview release, and the package is currently in active development. API can change in the near future. I appreciate your feedback, thanks.
big.js
and bigdecimal
)const { BigDecimal } = require('bigdecimal.js');
const x = BigDecimal.fromValue('1.1111111111111111111111');
const y = BigDecimal.fromValue(x);
const z = x.add(y);
console.log(z.toString()); // 2.2222222222222222222222
const x = BigDecimal.fromValue(1.1);
const y = BigDecimal.fromValue(2n);
console.log(x.toString()); // 1.1
console.log(y.toString()); // 2
npm i
npm run compile
npm test
There is a benchmark suite that compares
To run the benchmark run npm install
and then npm run benchmark
.
Generated using TypeDoc