I want to parse and convert an exponential value into a decimal using JavaScript. 4.65661287307739E-10
should give 0.000000000465661287307739
. What should I do to achieve this?
parseFloat(4.65661287307739E-10)
returns4.65661287307739e-10
.
parseInt(4.65661287307739E-10)
returns4
.
You can use toFixed()
, but there is a limit of 20.
ex:
(4.65661287307739E-10).toFixed(20) "0.00000000046566128731"
But...
(4.65661287307739E-30).toFixed(20) "0.00000000000000000000"
So if you always have fewer than 20 decimal places, you'll be fine. Otherwise, I think you may have to write your own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With