Test name | Executions per second |
---|---|
Native | 185946464.0 Ops/sec |
Native + toFixed | 6405164.5 Ops/sec |
decimal.js | 1012547.1 Ops/sec |
big.js | 1555679.0 Ops/sec |
bignumber.js | 926282.1 Ops/sec |
<!--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-->
var a = 0.1;
var b = 0.2;
((a + b) * b).toString();
var a = 0.1;
var b = 0.2;
((a + b) * b).toFixed(9);
var a = new Decimal("0.1");
var b = new Decimal("0.2");
a.plus(b).times(b).toString();
var a = new Big("0.1");
var b = new Big("0.2");
a.plus(b).mul(b).toString();
var a = new BigNumber("0.1");
var b = new BigNumber("0.2");
a.plus(b).multipliedBy(b).toString();