Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
bignumber.js vs. big.js vs. decimal.js (I)asd
(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 Native
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
new Decimal(1804) .mul(new Decimal(10).pow(6 - 18)) .log(1.0001) .round() .neg() .toNumber();
Native
Math.log(1804 * 10 ** (6 - 18)) / Math.log(1.0001)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
decimal.js
Native
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 what is being tested in this benchmark. **Benchmark Definition** The benchmark compares three different libraries: `bignumber.js`, `big.js`, and `decimal.js`. These libraries are designed to handle large numbers and mathematical operations that would be slow or unreliable with standard JavaScript arithmetic. **Options Compared** The benchmark tests the performance of each library for a specific mathematical operation: 1. **`decimal.js`**: This library performs the calculation using decimal arithmetic, which is more precise than standard JavaScript floating-point arithmetic. 2. **Native (Math)**: This option uses the built-in `Math` functions in JavaScript, such as `Math.log`, to perform the calculation. 3. **`bignumber.js`**, **`big.js`**: These libraries also perform decimal arithmetic, but with different optimizations and features. **Pros and Cons** * **`decimal.js`**: + Pros: More precise calculations, easy to use, and well-maintained. + Cons: May be slower than other options due to the overhead of decimal arithmetic. * **Native (Math)**: + Pros: Fastest option, widely supported, and well-integrated with JavaScript. + Cons: May produce imprecise results due to floating-point arithmetic limitations. * **`bignumber.js`**, **`big.js`**: + Pros: Fast performance, easy to use, and feature-rich (e.g., support for arbitrary-precision arithmetic). + Cons: May be more complex to use than `decimal.js`, and some features may not be as well-maintained. **Library Descriptions** * **`decimal.js`**: A library that provides decimal arithmetic for JavaScript. It is designed to be easy to use and provides a simple API for performing calculations. * **`bignumber.js`**: A library that provides arbitrary-precision arithmetic for JavaScript. It is designed to be fast and feature-rich, but may have a steeper learning curve. * **`big.js`**: A library that provides arbitrary-precision arithmetic for JavaScript. It is designed to be fast and easy to use, with a focus on simplicity. **Special JS Features or Syntax** None mentioned in this benchmark. **Other Alternatives** If you need high-performance arithmetic libraries, you may also consider: * **`Fraction.js`**: A library that provides rational arithmetic (fractions) for JavaScript. * **`Arbitrary-precision libraries like libgmpjs`**: These libraries provide arbitrary-precision arithmetic and are often used in scientific computing applications. Keep in mind that the choice of library depends on your specific use case, performance requirements, and ease of use preferences.
Related benchmarks:
bignumber.js vs. big.js vs. decimal.js (I) toFixed(9)
bignumber.js vs. big.js vs. decimal.js (I) no 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?