0

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.

Balraj McCoy
  • 125
  • 4

1 Answers1

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