Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
bignumber.js vs. big.js vs. decimal.js
(version: 0)
- https://github.com/MikeMcl/bignumber.js/tree/v9.0.0 - https://github.com/MikeMcl/big.js/tree/v5.2.2 - https://github.com/MikeMcl/decimal.js/tree/v10.2.0
Comparing performance of:
decimal.js vs big.js vs bignumber.js
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--script src="https://raw.githubusercontent.com/iriscouch/bigdecimal.js/v0.6.1/lib/bigdecimal.js"></script--> <script src="https://cdnjs.cloudflare.com/ajax/libs/bignumber.js/9.0.1/bignumber.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/big.js/6.0.3/big.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/decimal.js/10.2.1/decimal.min.js"></script> <!--script src="https://raw.githubusercontent.com/infusion/Fraction.js/v4.0.12/fraction.min.js"></script-->
Tests:
decimal.js
var a = new Decimal("0.1"); var b = new Decimal("0.2"); a.plus(b).times(b).toString();
big.js
var a = new Big("0.1"); var b = new Big("0.2"); a.plus(b).mul(b).toString();
bignumber.js
var a = new BigNumber("0.1"); var b = new BigNumber("0.2"); a.plus(b).multipliedBy(b).toString();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
decimal.js
big.js
bignumber.js
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of high-precision arithmetic libraries in JavaScript. **What are we testing?** We're comparing three popular libraries for working with large numbers in JavaScript: `big.js`, `bignumber.js`, and `decimal.js`. Specifically, we're measuring the performance of each library when performing simple arithmetic operations on two decimal values, followed by a multiplication operation. **Options being compared** 1. **`big.js`**: A library that provides support for arbitrary-precision arithmetic in JavaScript. It's designed to work with integers and floating-point numbers. 2. **`bignumber.js`**: A library that allows you to perform high-precision arithmetic operations on large decimal numbers. 3. **`decimal.js`**: A library that provides a fast and efficient way to work with decimal arithmetic, with support for arbitrary-precision arithmetic. **Pros and cons of each approach** 1. **`big.js`**: * Pros: Lightweight and efficient implementation of arbitrary-precision arithmetic. * Cons: May not be as intuitive or user-friendly as other libraries, especially for developers without prior experience with high-precision arithmetic. 2. **`bignumber.js`**: * Pros: Provides a simple and easy-to-use API for performing decimal arithmetic operations. * Cons: May be less efficient than `big.js` due to the overhead of parsing and formatting large numbers. 3. **`decimal.js`**: * Pros: Fast and efficient implementation of decimal arithmetic, with support for arbitrary-precision arithmetic. * Cons: May have a steeper learning curve due to its focus on high-performance decimal arithmetic. **Library usage** In the test cases, each library is used as follows: 1. **`decimal.js`**: Creates two `Decimal` objects from string literals and performs arithmetic operations on them using the `.plus()`, `.mul()` methods. 2. **`big.js`**: Creates two `Big` objects from string literals and performs arithmetic operations on them using the `.plus()`, `.mul()` methods. 3. **`bignumber.js`**: Creates two `BigNumber` objects from string literals and performs arithmetic operations on them using the `.plus()`, `.multipliedBy()` methods. **Special JavaScript features or syntax** None of the libraries rely on special JavaScript features or syntax, such as async/await or Promises. The tests focus solely on the performance of each library's arithmetic operations. **Alternatives** If you're looking for alternatives to these libraries, consider: 1. **`Fraction.js`**: A lightweight library for working with rational numbers. 2. **`Arbitrary.js`**: Another arbitrary-precision arithmetic library for JavaScript. 3. **`js-numberformat`**: A library for formatting and parsing numbers, including support for high-precision arithmetic. Keep in mind that the choice of library ultimately depends on your specific use case and performance requirements.
Related benchmarks:
bignumber.js vs. big.js vs. decimal.js (I) toFixed(9)
bignumber.js vs. big.js vs. decimal.js (I) no native
bignumber.js vs. big.js vs. decimal.js (without native)
Native.toFixed() vs bignumber.js vs big.js vs decimal.js
bignumber.js vs. big.js vs. decimal.js@10.4.3 (I)
Comments
Confirm delete:
Do you really want to delete benchmark?