MikeMcl / bignumber.js

A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
http://mikemcl.github.io/bignumber.js
MIT License
6.63k stars 743 forks source link

Enormous CPU times using large DECIMAL_PLACES with hex numbers #342

Open Meemaw opened 1 year ago

Meemaw commented 1 year ago

Seeing some enormous CPU times when using high DECIMAL_PLCAES config with hex numbers. The following code takes ~30s to finish on a high end computer.

Removing the DECIMAL_PLCAES option (or making it smaller), maker things better.

import { BigNumber } from "bignumber.js";

BigNumber.config({
  DECIMAL_PLACES: 1e9
});

BigNumber("0x9a864287d")