Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119
Windows
Desktop
one year ago
Test name Executions per second
Native 113161664.0 Ops/sec
Native + toFixed 5652150.0 Ops/sec
decimal.js 536822.8 Ops/sec
big.js 1022234.9 Ops/sec
bignumber.js 595260.8 Ops/sec
HTML Preparation code:
x
 
1
<!--script src="https://raw.githubusercontent.com/iriscouch/bigdecimal.js/v0.6.1/lib/bigdecimal.js"></script-->
2
<script src="https://cdnjs.cloudflare.com/ajax/libs/bignumber.js/9.0.1/bignumber.min.js"></script>
3
<script src="https://cdnjs.cloudflare.com/ajax/libs/big.js/6.0.3/big.min.js"></script>
4
<script src="https://cdnjs.cloudflare.com/ajax/libs/decimal.js/10.2.1/decimal.min.js"></script>
5
<!--script src="https://raw.githubusercontent.com/infusion/Fraction.js/v4.0.12/fraction.min.js"></script-->
6
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();