2

Possible Duplicate:
How to deal with big numbers in javascript

Javascript does't hold numbers > 17 digits. is there any other way to put bigger number into a variable? apart from parsing it into string?

example:

var x = 12647586984746263548565656;
alert(x);

Try this out. it wont work since x is a large number.

Community
  • 1
  • 1
  • 2
    No, unless you create your own JavaScript engine (or parser) which would maybe automatically convert such numbers into strings. Of course there are libraries to help you to work with large numbers, but even with them, you would not be able to use large number literals that exceed the maximum value. – Felix Kling Jun 19 '12 at 10:18
  • There are several libraries that converts a number into strings! but what if u want to pass an array of numbers and do manipulations with it? converting number into string doesn't help me! – user1450516 Jun 19 '12 at 11:53
  • As I said, if you have to these large numbers in your *source*, nothing can help you. Create them as strings from the beginning. A practical example: Since tweet IDs became so large, the Twitter API also includes a string version of the ID so that JavaScript clients can process it properly. – Felix Kling Jun 19 '12 at 12:00
  • i know tat! but i was jus wondering if i can do somethin from the client side itself! :) thanks a lot anyways! – user1450516 Jun 20 '12 at 05:29

0 Answers0