Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
bignumber.js vs. big.js vs. decimal.js big num 10** 18
(version: 0)
- https://github.com/MikeMcl/bignumber.js/tree/v9.0.2 - https://github.com/MikeMcl/big.js/tree/v5.2.2 - https://github.com/MikeMcl/decimal.js/tree/v10.2.0
Comparing performance of:
Native vs Native + toFixed vs 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.2/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:
Native
var a = 10000000000000000001.11; var b = 100000000000000000010.21; ((a + b) * b).toString();
Native + toFixed
var a = 10000000000000000001.11; var b = 10000000000000000001.21; ((a + b) * b).toFixed(9);
decimal.js
var a = new Decimal("10000000000000000001.11"); var b = new Decimal("10000000000000000001.21"); a.plus(b).times(b).toString();
big.js
var a = new Big("10000000000000000001.11"); var b = new Big("10000000000000000001.21"); a.plus(b).mul(b).toString();
bignumber.js
var a = new BigNumber("10000000000000000001.11"); var b = new BigNumber("10000000000000000001.21"); a.plus(b).multipliedBy(b).toString();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Native
Native + toFixed
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 details of what's being tested on MeasureThat.net. **What is being tested?** The benchmark is testing the performance of different libraries for handling large decimal numbers: 1. `bignumber.js` 2. `big.js` 3. `decimal.js` Each library has its own implementation of arithmetic operations (addition, multiplication, etc.) and formatting functions (e.g., `toFixed()`). **Options being compared** The benchmark is comparing the performance of each library under two different scenarios: 1. **Native**: This option uses the built-in JavaScript support for decimal numbers, which is implemented in the ECMAScript standard. 2. **Native + toFixed**: This option adds an additional formatting step using the `toFixed()` function. **Pros and Cons** Here's a brief summary of each library's pros and cons: * **bignumber.js** + Pros: High-performance arithmetic operations, supports arbitrary-precision numbers, easy to use. + Cons: Steeper learning curve due to its custom syntax and API. * **big.js** + Pros: Fast and efficient, supports decimal arithmetic with high precision, relatively simple API. + Cons: Smaller community support compared to bignumber.js, some users find the API less intuitive. * **decimal.js** + Pros: Robust implementation of decimal arithmetic, easy to use, widely adopted in financial and scientific applications. + Cons: Slower performance compared to bignumber.js and big.js, more complex API. **Other considerations** When choosing a library for handling large decimal numbers, consider the following factors: * **Performance**: If high-performance arithmetic operations are crucial, bignumber.js or big.js might be a better choice. Otherwise, decimal.js' robust implementation and ease of use might be more suitable. * **API simplicity**: If you prefer a simple and intuitive API, decimal.js or bignumber.js might be a better fit. Big.js has a relatively straightforward API but may require some learning curve for advanced users. * **Community support**: If you need help with the library or want to contribute to its development, consider the size of each library's community. **Library descriptions** Here's a brief description of each library: * **bignumber.js**: Developed by Mike McLaughlin, this library provides high-performance arithmetic operations for arbitrary-precision numbers. It's widely used in financial and scientific applications. * **big.js**: Created by the Big.js project team, this library offers fast and efficient decimal arithmetic with high precision. It's designed for use cases where simple, intuitive API is sufficient. * **decimal.js**: Developed by Mike McLaughlin (same author as bignumber.js), this library provides a robust implementation of decimal arithmetic with high precision. It's widely adopted in financial and scientific applications due to its ease of use and reliability. **Special JS features or syntax** None of the libraries mentioned above uses special JavaScript features or syntax that would require additional explanation.
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?