Closed cemremengu closed 5 years ago
My bad, needed to use toPrecision
. Sorry for the noise.
Although docs seem to be incorrect for toPrecision
If sd is omitted, or is null or undefined, then the return value is the same as n.toString().
which is not the case
To avoid scientific notation then either use toFixed() or change the value of EXPONENTIAL_AT:
const n = new BigNumber('5000310000187400001874');
console.log(n.toFixed()); // "5000310000187400001874"
console.log(n.toString()); // "5.000310000187400001874e+21"
BigNumber.set({EXPONENTIAL_AT: 25});
console.log(n.toString()); // "5000310000187400001874"
There is no reason to use toPrecision
without an argument, but in doing so you have discovered a mismatch between the documentation and behaviour. I will fix this presently. Thanks for the report.
Expected: "5000310000187400001874" Actual: "5.000310000187400001874e+21"
https://runkit.com/cemremengu/5c10eb8866628400131646bc