0

I have a string in response "2.222222522879E12",

When I do

parseFloat("2.222222522879E12")
2222222522879

But the expected value should be 2.22, Whats happening ?

And how can I fix it

Rahul Shivsharan
  • 2,481
  • 7
  • 40
  • 59

1 Answers1

3

You're going to get 2.222222522879* 10^12 with that expression as E means exponent, or to the power of

As per your edit asking how to fix:

use the Number.prototype.toPrecision() function. Here is the documentation

Barney Chambers
  • 2,720
  • 6
  • 42
  • 78