Decimal.js: Detailed Overview & Metrics

v10.4.3(10 months ago)

This package is actively maintained.Types definitions are bundled with the npm packageNumber of direct dependencies: 0Monthly npm downloads

Decimal.js is a JavaScript library for precise decimal arithmetic. It provides a reliable and accurate way to perform calculations with decimal numbers, avoiding the common rounding errors and precision issues that can occur with floating-point arithmetic in JavaScript.

With Decimal.js, you can perform operations like addition, subtraction, multiplication, and division with decimal numbers of any size and precision. It supports a wide range of mathematical functions and allows you to control the rounding mode and precision settings for your calculations.

Compared to the built-in JavaScript Number type, Decimal.js offers more control and accuracy when working with decimal numbers. It is particularly useful in financial and scientific applications where precision is crucial.

As an alternative, you can consider using the BigNumber.js library, which provides similar functionality for arbitrary-precision arithmetic.

Alternatives: bignumber.js, math.js, big.js

Tags: javascriptdecimalarithmeticprecisionmath