big.js is a compact JavaScript library for arbitrary-precision decimal arithmetic. It avoids many floating-point accuracy problems that occur with JavaScript’s native Number type. Values are stored using a decimal coefficient, exponent, and sign rather than ordinary binary floating-point representation. Its API supports arithmetic, comparisons, powers, square roots, rounding, and common numeric formatting methods. Precision and rounding behavior can be configured for operations such as division. The library has no runtime dependencies and is only about 6 KB when minified. It supports browsers, Node.js, ES modules, CommonJS, and other JavaScript environments while keeping the API deliberately smaller than bignumber.js or decimal.js.
Features
- Arbitrary-precision decimal arithmetic
- Addition, subtraction, multiplication, and division
- Square roots and integer powers
- Configurable decimal places and rounding
- CommonJS and ES module support
- Dependency-free 6 KB minified library