1

I have a weird (and rather frightening) problem with Ajax.
I'm returning 3 large integers from PHP back to Javascript (jQuery):
9849933840800076
9717106838244944
9261288452893495
But recieve:
9849933840800076
9717106838244944
9261288452893496

Notice the last digit in the third integer - WTF ?!?
- I'm logging everything, and am certain it's not my code doing it!
And returning them as strings instead does solve the problem, but still...
It would be nice to get an explanation - and some sleep : )

T4NK3R
  • 4,245
  • 3
  • 23
  • 25

2 Answers2

2

My fault, sorry. (and thank you, Pekka)
JS "looses precision" on integers larger than 2^53 (+/- 9007199254740992)
- Back to the wriggleroom..

T4NK3R
  • 4,245
  • 3
  • 23
  • 25
0

in these kind of cases you can always return the numbers as strings and convert them in the js

zion ben yacov
  • 715
  • 6
  • 13