For example, I have a number which is 1.3685999999999998e+35 but I just want to display 1.368e+35. I tried toFixed and toPrecision but nothing works.
Asked
Active
Viewed 237 times
0
-
Possible Duplicate http://stackoverflow.com/questions/11124451/how-can-i-convert-numbers-into-scientific-notation – Shakir Ahamed Sep 14 '16 at 04:06
1 Answers
3
You need to use Number.prototype.toExponential
:
var x = 11827361827361872361263812631827361823618723;
console.log(x.toExponential(2));
console.log(x.toExponential(3));
console.log(x.toExponential(10));

Yeldar Kurmangaliyev
- 33,467
- 12
- 59
- 101