when ‘facebookID’ is an integer with equal or less than 10 digits, everything works well. But as soon as it has 11 or more digits, corona simulator changes it after reload. Value “12345678901” becomes “-539222987” after restart of the app.
I guess there is a simple explanation for this behaviour, can anyone help me out? Also, how can I solve this?
Im on windows, yes. When I print facebookID right after it was set, it works perfectly. But when I comment out the
– system.setPreferences(…
after restart it doesnt print the right value out any more. It does so as long as the string has less than 10 digits though OR as long as there is a character also. Weird…
What I still dont understand though: Why does the correct value gets printed out until the app is reloaded for the first time? Does that mean simulator saves it somehow different and then, only when I reload the app, windows takes over and the problem occurs?
Still, if it’s a string and you never convert it to a number it should stay a string and running in to maxint shouldn’t come into play. I just did a test on Windows in a clean/new project with just these two lines of code:
which means it overflowed Lua’s ability to represent a number as an integer (all numbers are double floats, but Lua uses some trick of using doubles to represent int’s as ints) so it represented it as a double float and that’s probably the appropriate value.
I would look through your code and make sure you’re not treating the value as a number somewhere. You can copy and paste the code above into a new project and see if you get the same results.
I can confirm this is an issue on Windows, but not on macOS. Can I get you to make a small demo project, complete with config.lua, build.settings and main.lua and put it in a .zip file and use the Report a Bug link at the top of the page.
Here you go. I just clicked on “new project” in simulator, added the two lines in main.lua and tried again. Same result: “12345678901” becomes -539222987
Hope that helps
/edit: Oh I missed the “bug report” part. I’ll now report it