0

I'm trying to calculate Math.pow(2,1000) and I am getting Result : "1.0715086071862673e+301"

If I try Math.pow(2,10000), then I get Result : "Infinity".

Can anyone help me to solve this using javascript?

Bojangles
  • 96,145
  • 48
  • 166
  • 203
Darkpiece
  • 111
  • 5

2 Answers2

2

You can also try https://github.com/peterolson/BigInteger.js for big number calculation.

Prabhuram
  • 1,288
  • 9
  • 15
0

You can't calculate such large numbers solely with JavaScript, you will probably need to use a library for that.

Please take a look at https://github.com/jtobey/javascript-bignum or http://jsfromhell.com/classes/bignumber

Dropout
  • 13,107
  • 9
  • 51
  • 105