decimalic
v1.0.1
Published
A small pack of utils for arbitrary-precision number calculations. Based on 'decimal.js-light'.
Downloads
7
Maintainers
Readme
Decimalic
A small pack of utils for arbitrary-precision number calculations. Based on 'decimal.js-light'.
Usage
Require CommonJS.
const { Decimal, diff, divide, multiply, sum } = require("decimalic");
Import as ECMAScript module.
import { Decimal, diff, divide, multiply, sum } from "decimalic";
Examples
Diff
import { diff } from "decimalic";
console.log(2.3 - 1.0); // 1.2999999999999998
console.log(diff(2.3, 1.0)); // 1.3
Divide
import { divide } from "decimalic";
console.log(5.3 / 0.1); // 52.99999999999999
console.log(divide(5.3, 0.1)); // 53
Multiply
import { multiply } from "decimalic";
console.log(2232.0 * 0.1); // 223.20000000000002
console.log(multiply(2232.0, 0.1)); // 223.2
Sum
import { sum } from "decimalic";
console.log(2.3 + 1.15); // 3.4499999999999997
console.log(sum(2.3, 1.15)); // 3.45