Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
bignumber.js vs. big.js vs. decimal.js vs. Fraction.js (without native)
(version: 0)
- https://github.com/iriscouch/bigdecimal.js/tree/v0.6.1 - 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 - https://github.com/infusion/Fraction.js/tree/v4.0.12
Comparing performance of:
decimal.js vs big.js vs bignumber.js vs bigdecimal.js vs Fraction.js
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/bigdecimal@0.6.1/lib/bigdecimal.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bignumber.js@9.0.1/bignumber.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/big.js@6.0.3/big.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/decimal.js@10.2.1/decimal.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/fraction.js@4.0.13/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();
bigdecimal.js
var a = new BigDecimal("0.1"); var b = new BigDecimal("0.2"); a.add(b).multiply(b).toString();
Fraction.js
var a = new Fraction("0.1"); var b = new Fraction("0.2"); a.add(b).mul(b).toString();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
decimal.js
big.js
bignumber.js
bigdecimal.js
Fraction.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 world of JavaScript microbenchmarks! **What is being tested?** MeasureThat.net is testing various libraries that provide support for decimal arithmetic, specifically: 1. `bignumber.js`: A library for high-precision floating-point numbers. 2. `big.js`: A library that provides support for decimal arithmetic with a focus on simplicity and ease of use. 3. `decimal.js`: A widely-used library for working with decimal numbers in JavaScript. 4. `Fraction.js` (without native): A library for working with rational numbers. **Options compared** The tests compare the performance of each library when performing basic arithmetic operations, such as addition, multiplication, and concatenation, on two decimal numbers: * `var a = new Decimal("0.1"); var b = new Decimal("0.2");` * `var a = new Big("0.1"); var b = new Big("0.2");` * `var a = new BigNumber("0.1"); var b = new BigNumber("0.2");` * `var a = new BigDecimal("0.1"); var b = new BigDecimal("0.2");` * `var a = new Fraction("0.1"); var b = new Fraction("0.2");` **Pros and cons of each approach** Here's a brief summary of the pros and cons of each library: 1. **bignumber.js**: * Pros: High precision, fast execution. * Cons: Steeper learning curve due to advanced features. 2. **big.js**: * Pros: Simple and intuitive API, good performance. * Cons: May not be suitable for high-precision arithmetic. 3. **decimal.js**: * Pros: Wide adoption, stable API, good performance. * Cons: May have limitations in precision or speed for very large numbers. 4. **Fraction.js** (without native): * Pros: Lightweight, easy to use, suitable for rational numbers. * Cons: Limited support for decimal arithmetic. **Special JS features** None of the libraries mentioned in the benchmark require any special JavaScript features or syntax beyond standard arithmetic operations. **Other alternatives** If you're looking for alternative libraries that provide similar functionality, consider: 1. **big-integer.js**: A library for high-precision integer arithmetic. 2. **js-math**: A comprehensive mathematics library with support for decimal arithmetic. 3. **decimal-arithmetic**: A lightweight library for decimal arithmetic. Keep in mind that each library has its strengths and weaknesses, and the choice ultimately depends on your specific use case and requirements. I hope this explanation helps you understand what's being tested in MeasureThat.net!
Related benchmarks:
bignumber.js vs. big.js vs. decimal.js vs. Fraction.js (20220325)
bignumber library vs native benchmark: compareTo
bignumber.js vs native benchmark: string to number
number vs bignumber.js vs big.js vs decimal.js
Comments
Confirm delete:
Do you really want to delete benchmark?