Out of curiosity, I looked into the precise limits on integer size in Lua (our Lua, like most, uses 8 byte doubles to represent numbers).
Consider this code fragment:
local maxdouble = 2^53 -- one less than the maximum can be represented precisely print (string.format("%.0f",maxdouble-1)) --\> 9007199254740991 -- the maximum itself can be represented precisely print (string.format("%.0f",maxdouble)) --\> 9007199254740992 -- one more than the maximum gets rounded down print (string.format("%.0f",maxdouble+1)) --\> 9007199254740992 again
Output:
2014-05-27 11:24:20.996 Corona Simulator[60038:303] maxdouble-1 (9007199254740991): 9007199254740991 2014-05-27 11:24:20.996 Corona Simulator[60038:303] maxdouble (9007199254740992): 9007199254740992 2014-05-27 11:24:20.997 Corona Simulator[60038:303] maxdouble+1 (9007199254740992): 9007199254740992
So you can represent integers towards the upper end of 16 digits but the wheels come off when you go greater than 2^53.
Add a leading digit (to the example value supplied):
local mynumber = 23334445556667711 print (string.format("mynumber-1 (23334445556667710): %.0f",mynumber-1)) --\> should be 23334445556667710 print (string.format(" mynumber (23334445556667711): %.0f",mynumber)) --\>should be 23334445556667711 print (string.format("mynumber+1 (23334445556667712): %.0f",mynumber+1)) --\>should be 23334445556667712
And the output is incorrect (actually, and unfortunately, it’s close enough to the original number that you might not notice for a while that you’re in trouble):
2014-05-27 11:24:20.999 Corona Simulator[60038:303] mynumber-1 (23334445556667710): 23334445556667712 2014-05-27 11:24:21.000 Corona Simulator[60038:303] mynumber (23334445556667711): 23334445556667712 2014-05-27 11:24:21.001 Corona Simulator[60038:303] mynumber+1 (23334445556667712): 23334445556667712
Note that the same thing would happen if your 16 digit number happens to have greater than 90 for its first two digits.
So remember that Lua doesn’t actually support 64-bit integers, though it gets fairly close. Things that are opaque ids should be transmitted as strings. If you want to do math with them, then you’ll have make your own arrangements for arbitrary precision numbers.