-1

I need to create a Long variable using JavaScript, like you can do normally in Java by executing this code:

long n = 3;

My problem is that I need "n" to be very very big, exceeding the range of an integer, because I'm doing big number calculus. Do you know any way to create that? The "var" type of data is long enough for this?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user2335355
  • 11
  • 1
  • 1
  • 1
    Please ***read*** the helpful tag pop-ups before you go slapping them on a question! – Andrew Thompson Apr 30 '13 at 09:59
  • 1
    JavaScript numbers are 64bit. If you exceed this range (and still need exact results), you will have to use a big-number lib. – Sirko Apr 30 '13 at 09:59
  • 1
    possible duplicate of [How to deal with big numbers in javascript](http://stackoverflow.com/questions/4288821/how-to-deal-with-big-numbers-in-javascript) – Thilo Apr 30 '13 at 10:00
  • Why are you asking if it is long enough? Have you not tried it yet? – Skepi Apr 30 '13 at 10:01
  • 1
    `var` is not a type. I encourage you to read up on JavaScript numbers before doing this or you will have some very nasty shocks. – Joe Apr 30 '13 at 10:07

2 Answers2

0

BigInteger library is an option for you

giorgian
  • 3,795
  • 1
  • 30
  • 48
Vinay Pandey
  • 8,589
  • 9
  • 36
  • 54
0

There are some libraries that allow integers with arbitrary precision, notably:

giorgian
  • 3,795
  • 1
  • 30
  • 48