Search code examples
javascriptmatheulers-number

Any way to get JavaScript numbers without Euler's number


I try to get

Math.pow(2,1000);

The result is " 1.2676506002282294e+30 "

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


Solution

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