What does 1e+24 Chrome console mean?

Asked

Viewed 2,170 times

6

I noticed that when I type in Chrome console 1000000000000000000000000 he returns me 1e+24.

And when I type 1000000000000000009901591 he also returns to me 1e+24 whereas 1000000000000000000000000 is different from 1000000000000000009901591

  1. Why does that happen?
  2. And how to differentiate the two?

1 answer

11


That’s an exponential representation. It is not possible to differentiate the two because these numbers extrapolate the maximum precision of the numeric type used by javascript, which is below the screens a type double of IEEE 754 standard.

The exponential representation works like this:

Mand+And => M 10And

Mand-And => M 10-And

For the given number, we have M = 1, and E = 24 positive. Then the final value will be:

1 1024, 1 followed by 24 zeros.

  • In this case, Chrome uses the V8 and it is possible to confirm the double that Miguel Angelo said for the documentation: http://izs.me/v8-docs/classv8_1_1Number.html

  • Note that this standard (IEEE 754, used by most processors) does not allow specifying more than 17 significant digits. And the 17th is often a rounding.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.