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
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
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