Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
bigint vs. bignumber.js vs. big.js vs. decimal.js with exponentiation4
(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 BigInt vs decimal.js
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/decimal.js/10.2.1/decimal.min.js"></script>
Tests:
Native
var a = 100; var b = 200000; var c = 31; (((a + b) * b) ** c).toString();
BigInt
var a = 100n; var b = 200000n; var c = 31n; (((a + b) * b) ** c).toString();
decimal.js
var a = new Decimal("100"); var b = new Decimal("200000"); var c = new Decimal("31"); a.plus(b).times(b).pow(c).toString();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Native
BigInt
decimal.js
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser/OS:
Chrome 121 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Native
75043224.0 Ops/sec
BigInt
248487.8 Ops/sec
decimal.js
137155.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the provided benchmark and explain what's being tested, compared, and considered. **Benchmark Overview** The provided JSON represents a JavaScript microbenchmark test case on MeasureThat.net. The goal is to compare the performance of different libraries and built-in JavaScript features when performing arithmetic operations with large numbers (BigInts) and decimal values. **Libraries Compared** Three libraries are being tested: 1. **Big.js**: A library for working with large integers in JavaScript. 2. **Bignumber.js**: A library for dealing with large numbers in JavaScript, providing more precise calculations than the built-in `Number` type. 3. **Decimal.js**: A library for performing decimal arithmetic operations. **Built-in JavaScript Features Compared** Two built-in JavaScript features are being tested: 1. **Native**: The native implementation of BigInts in JavaScript, which was introduced in ECMAScript 2020 (ES2020). 2. **BigInt**: The built-in `Number` type with the `n` suffix, which allows for literal BigInt literals. **Options Compared** Each benchmark test case compares a different option: 1. Native: The native implementation of BigInts. 2. Big.js: A library-based approach using Big.js. 3. Bignumber.js: A library-based approach using Bignumber.js. 4. Decimal.js: A library-based approach using Decimal.js. **Pros and Cons** Here's a brief summary of the pros and cons for each option: * **Native (BigInt)**: + Pros: Native implementation, potentially more efficient due to just-in-time compilation. + Cons: May not work in older browsers or environments that don't support BigInts. * **Big.js**: + Pros: More control over arithmetic operations, potentially more efficient than native implementation. + Cons: Requires additional library dependency and setup. * **Bignumber.js**: + Pros: Provides a more precise calculation experience compared to the built-in `Number` type. + Cons: Additional library dependency and setup required. * **Decimal.js**: + Pros: Provides a more precise decimal arithmetic experience, potentially more efficient than native implementation. + Cons: Additional library dependency and setup required. **Special JavaScript Features/Syntax** The benchmark uses the following special JavaScript feature: * **BigInts**: The native `Number` type with the `n` suffix for literal BigInt literals. This is a relatively new feature introduced in ECMAScript 2020 (ES2020). **Other Alternatives** There are other libraries and approaches available for working with large numbers and decimal arithmetic, such as: * **Big.js**: A more mature library for large integers. * **Decimal.js**: A library providing more precise decimal arithmetic operations. * **BN.js**: A library for arbitrary-precision arithmetic. However, the benchmark is specifically designed to compare the performance of Big.js, Bignumber.js, and Decimal.js with the native implementation of BigInts and built-in `Number` type.
Related benchmarks:
bignumber.js vs. big.js vs. decimal.js only calculation without toString()
number / bignumber.js / big.js / decimal.js
number vs bignumber.js vs big.js vs decimal.js
bigint vs. bignumber.js vs. big.js vs. decimal.js with exponentiation
Native.toFixed() vs bignumber.js vs big.js vs decimal.js
Comments
Confirm delete:
Do you really want to delete benchmark?