Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
bignumber.js vs. big.js vs. decimal.js (1)
(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:
2 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:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser/OS:
Chrome 130 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
decimal.js
466274.6 Ops/sec
big.js
844756.4 Ops/sec
bignumber.js
456431.7 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll explain the benchmark and its components in detail. **Benchmark Overview** The MeasureThat.net benchmark compares the performance of three libraries: `big.js`, `bignumber.js`, and `decimal.js`. These libraries are designed to handle large numbers and decimal arithmetic, which is essential for various applications, such as finance, science, and engineering. **Library Descriptions** 1. **`big.js`**: This library provides a simple and lightweight way to work with integers and decimals. It's based on the `big-integer` algorithm, which uses a binary representation of numbers to perform arithmetic operations. 2. **`bignumber.js`**: This library is designed for high-performance decimal arithmetic. It uses a custom implementation of the decimal format, which allows for efficient calculations and conversions between different number formats. 3. **`decimal.js`**: This library provides a more advanced way to work with decimals, including support for arbitrary-precision arithmetic and conversion to other number formats. **Options Compared** The benchmark compares the performance of these three libraries on a specific test case: * `decimal.js`: Performs decimal arithmetic using the `Decimal` class. * `big.js`: Performs integer arithmetic using the `Big` class ( note: this is not true big number, it's more like arbitrary-precision integer ) and uses a binary representation of numbers for calculations. * `bignumber.js`: Performs decimal arithmetic using the `BigNumber` class. **Pros and Cons** 1. **`decimal.js`**: * Pros: Supports arbitrary-precision arithmetic, easy to use API, fast performance. * Cons: May have slower performance compared to `bignumber.js`, not as optimized for high-performance calculations. 2. **`big.js`**: * Pros: Lightweight, simple API, suitable for small-scale applications. * Cons: Not designed for high-precision arithmetic, may not be suitable for large numbers or complex calculations. 3. **`bignumber.js`**: * Pros: High-performance decimal arithmetic, optimized for conversions and calculations between different number formats. * Cons: May have steeper learning curve due to its custom implementation, slower performance compared to `decimal.js`. **Special Considerations** The benchmark assumes that the test user will be working with decimal numbers and requires libraries that support decimal arithmetic. The use of `fraction.js` library is skipped in this benchmark. **Alternatives** If you need a lightweight solution for small-scale applications or integer arithmetic, `big.js` might be suitable. For high-performance decimal arithmetic, `bignumber.js` is recommended. If you require arbitrary-precision arithmetic and ease of use, `decimal.js` could be the best choice. Keep in mind that these libraries have different design goals and use cases. Thoroughly evaluating their pros and cons will help you choose the most suitable library for your specific needs.
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?