Parsing and converting exponential values to decimal in JavaScript

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.

Leave a Comment