A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic.
bignumber.js is a JavaScript library for arbitrary-precision arithmetic, supporting both decimal and non-decimal numbers. It provides accurate mathematical operations beyond the limits of JavaScript's native Number type, eliminating floating-point errors in calculations. The library is essential for applications requiring high precision, such as financial systems, scientific computing, and cryptography.
JavaScript developers working on financial applications, scientific simulations, cryptographic systems, or any project where numerical precision is critical. It's also suitable for educators and researchers needing reliable big number arithmetic in web environments.
Developers choose bignumber.js for its combination of performance, small footprint, and comprehensive feature set. It offers a simpler and faster alternative to other big number libraries while maintaining full compatibility with JavaScript's Number methods and supporting advanced features like cryptographically secure random number generation.
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports unlimited precision integers and decimals, eliminating floating-point errors common in JavaScript's native Number type, as shown in examples like accurate 0.3 - 0.1 calculations.
Replicates JavaScript's Number methods (e.g., toExponential, toFixed) and adds extras like toFraction and squareRoot, making it easy to adopt for developers already familiar with standard APIs.
At 8 KB minified and gzipped with no dependencies, it's faster and smaller than alternatives like Java's BigDecimal in JavaScript, ensuring efficient loading and execution.
Uses only ECMAScript 3 features, making it compatible with all browsers and environments, including legacy systems, without polyfills or extra setup.
For operations involving division or base conversion, users must manually set DECIMAL_PLACES and ROUNDING_MODE via config methods, adding complexity compared to libraries with defaults tailored to specific use cases.
While it handles basic arithmetic well, it lacks built-in support for advanced functions like trigonometry or logarithms, which are available in more specialized libraries such as decimal.js.
Due to immutable objects and arbitrary precision, it can be slower than native JavaScript numbers for straightforward calculations, making it overkill for applications where precision isn't critical.