-2

I try to get

Math.pow(2,1000);

The result is " 1.2676506002282294e+30 "

I need the number without Euler's number "e+30"

Mostafa Nawara
  • 782
  • 9
  • 21
  • 7
    It's not Euler's numbers... that's 2.718 lol – Michael Zhang Jun 17 '16 at 15:00
  • 4
    Also check this out: http://stackoverflow.com/questions/1685680/how-to-avoid-scientific-notation-for-large-numbers-in-javascript – Michael Zhang Jun 17 '16 at 15:02
  • That's called _exponential notation_. Take a look at [this other question](http://stackoverflow.com/questions/1685680/how-to-avoid-scientific-notation-for-large-numbers-in-javascript), it addresses the same problem =) – salezica Jun 17 '16 at 15:04

2 Answers2

2

With very large numbers, JavaScript displays them in scientific notation. This is because it is very expensive and unreadable to list them.

For your example, it basically means

1.2676506002282294 * 10 ^ 30

You take the number and then multiply it by 10 to the 30th power.

Calculators often use "E" or "e" like this: 1.8004E+94

6E+5 is the same as 6 × 10^5

To get it without this notation, simply use smaller numbers as the exponent.

Example: Math.pow(2,10)

Mathisfun provides an excellent article on scientific notation. Check it out here

https://www.mathsisfun.com/numbers/scientific-notation.html

Euler's number is a constant that is the base of a natural number. It's an irrational number, meaning its digits go on forever. The first couple digits are 2.7182818284

Community
  • 1
  • 1
Richard Hamilton
  • 25,478
  • 10
  • 60
  • 87
2

That's scientific notation, not Euler's number.

If you want to show the number without the e+NN part:

  • convert it to a string
  • parse the e+NN part
  • shift the decimal place the appropriate number of digits
  • return the output as a string

be aware that doing so will lead to inaccurate values for some calculations due to how floating point arithmetic works.

zzzzBov
  • 174,988
  • 54
  • 320
  • 367