I'm creating a idle html5/js game where I use bignumber.js library to be able to store arbitrarly long numbers, as I requirement for a idle game. The problem is that when in the configuration I have the EXPONENTIAL_AT option setted to some number, and after the variable expoent is larger than EXPONENTIAL_AT, the decimalPlaces function don't work, it shows something like "2.93012393841298e+23" even with "largeNumber.decimalPlaces(4)".
Currently, part of the script is somewhat this:
BigNumber.config({
DECIMAL_PLACES: 4,
EXPONENTIAL_AT: 16,
ROUNDING_MODE: BigNumber.ROUND_HALF_UP
});
var largeNumber = new BigNumber("10594.1931247123691823e+23");
console.log(largeNumber.dp(4).toString());
This shows in console: 1.05941931247123691823e+27
, so the exponential notation works, but the rounding not.
I don't know what I'm doing wrong or if is a bug, but I would like that this should work as expected.