Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert 1e-8 to 0.00000001 in JavaScript

How do I convert 1e-8 to 0.00000001 in JavaScript?

I'm using Angular and it does not like the short syntax when using <input type="number">.

like image 351
chovy Avatar asked Feb 23 '14 20:02

chovy


1 Answers

Numbers have a toFixed(digits) method which will do this:

1e-8.toFixed(8);

If you've got a string, you first need to convert it to a number:

parseFloat('1e-8').toFixed(8);
like image 152
YMMD Avatar answered Nov 14 '22 23:11

YMMD