Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
bignumber.js vs. big.js vs. decimal.js (2)
(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:
Native vs Native + toFixed vs decimal.js vs big.js vs bignumber.js
Created:
4 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:
Native
var a = 0.1; var b = 0.2; ((a + b) * b).toString();
Native + toFixed
var a = 0.1; var b = 0.2; ((a + b) * b).toFixed(9);
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 (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 explanation of the benchmark. **Benchmark Overview** The benchmark measures the performance of three libraries for arbitrary-precision arithmetic: `big.js`, `decimal.js`, and `bignumber.js`. The benchmarks compare the execution speed of these libraries when performing basic arithmetic operations, such as addition, multiplication, and string conversion. There are two variations in each library: * "Native" - uses the built-in support for arbitrary-precision arithmetic in JavaScript * "Native + toFixed" - adds a `toFixed` method, which can affect performance **Library Overview** 1. **Decimal.js**: A library specifically designed for decimal arithmetic with support for rounding, scaling, and formatting. 2. **Big.js**: A library that provides a simple and efficient way to perform arbitrary-precision arithmetic using a compact binary representation. 3. **Bignumber.js**: A library that offers more advanced features than Big.js, including support for multiple precision formats and a more extensive set of mathematical functions. **Options Compared** The benchmark compares the execution speed of each library with the following options: * "Native": uses the built-in support for arbitrary-precision arithmetic in JavaScript * "Native + toFixed": adds a `toFixed` method, which can affect performance **Pros and Cons** 1. **Decimal.js** * Pros: provides accurate results due to its focus on decimal arithmetic; supports rounding, scaling, and formatting. * Cons: may be slower than other libraries for basic arithmetic operations. 2. **Big.js** * Pros: provides fast execution speed due to its compact binary representation; easy to use. * Cons: limited mathematical functions compared to Bignumber.js. 3. **Bignumber.js** * Pros: offers more advanced features, including multiple precision formats and a wider range of mathematical functions. * Cons: may be slower than Big.js for simple arithmetic operations. **Other Considerations** When choosing an arbitrary-precision arithmetic library, consider the specific requirements of your project: * Accuracy vs. speed: If accuracy is crucial, choose Decimal.js or Bignumber.js. For faster execution, use Big.js. * Mathematical functions: If you need a wide range of mathematical functions, choose Bignumber.js. * Ease of use: Big.js and Bignumber.js have more user-friendly APIs than Decimal.js. **Alternative Libraries** If you're looking for alternative libraries, consider: 1. **Fraction.js**: A library for rational numbers that provides accurate results and support for arithmetic operations. 2. **Ratify.js**: A library that provides a more efficient way to work with rational numbers compared to Fraction.js. Keep in mind that each library has its strengths and weaknesses, so it's essential to evaluate your specific requirements before choosing a library.
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?