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

3
  • 7
    It's not Euler's numbers... that's 2.718 lol Commented Jun 17, 2016 at 15:00
  • 4
    Also check this out: stackoverflow.com/questions/1685680/… Commented Jun 17, 2016 at 15:02
  • That's called exponential notation. Take a look at this other question, it addresses the same problem =) Commented Jun 17, 2016 at 15:04

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.