Miss any of our Open RFC calls?Watch the recordings here! »

decimalic

1.0.1 • Public • Published

Decimalic

A small pack of utils for arbitrary-precision number calculations. Based on 'decimal.js-light'.

npm downloads stars types build lgtm


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

See also

My other projects

Install

npm i decimalic

DownloadsWeekly Downloads

6

Version

1.0.1

License

MIT

Unpacked Size

307 kB

Total Files

10

Last publish

Collaborators

  • avatar