Reputation: 21
I have a big problem with large values that I have to change from string to number with two decimal places.
Examples:
parseFloat('99999999999999.99')
What I get: 99999999999999.98
What I want to get: 99999999999999.99
parseFloat('99999999999999000000.00').toFixed(2)
What I get: '99999999999999000576.00'
What I want to get: '99999999999999000000.00'
parseFloat('999999999999999999999.99')
What I get: 1e+21
What I want to get: 999999999999999999999.99
Also, I have a problem with rounding:
(9.555).toFixed(2)
What I get: '9.55'
What I want to get: '9.56'
Is there any library that can help me with this problem? I really want the resulting value to be of type number.
I know is BigInt type, but I have decimals. I know is bignumber library, but the resulting values are strings.
Upvotes: 0
Views: 129