2

Possible Duplicate:
Huge Integer JavaScript Library

Suppose I want the exact value for 2^1000. How am I supposed to get the entire value? Maybe storing it in a string every time the multiplication is done, but it will still eventually go over 10 digits! Is there any way, or does ECMAScript just not support this?

Community
  • 1
  • 1
Some Guy
  • 15,854
  • 10
  • 58
  • 67
  • You can't. Javascript doesn't support 1000 bit integers. You're gonna have to invent your own system for storing and working with large numbers. – Eric Aug 04 '11 at 13:40
  • Oh. Alright. Any great insights from anyone as to how I could do something like this? – Some Guy Aug 04 '11 at 13:41
  • 1
    See Quentin's comment, or search on "big int javascript library". – RobG Aug 04 '11 at 13:43
  • Sounds like someone is missing the point of Project Euler - http://projecteuler.net/index.php?section=problems&id=16 – Gareth Aug 04 '11 at 13:50
  • Hahahaha, I am trying Project Euler, but I am not asking for a direct solution, just any ideas. I am not going to use the BigInt library to solve the problem directly. :D. Glad to see more Euler people on here. – Some Guy Aug 04 '11 at 13:52
  • This is actually a duplicate of http://stackoverflow.com/questions/377361/sum-of-the-digits-of-the-number-21000 but in terms of the problem would be a better fit for http://math.stackexchange.com/ – Gareth Aug 04 '11 at 13:56

1 Answers1

0
Math.pow(2,1000)

returns

1.0715086071862673e+301

how accurate do you need this to be?

Joseph Marikle
  • 76,418
  • 17
  • 112
  • 129