| |
Although Lua numbers are stored internally as double-precision reals, when they are saved in SavedVariables.lua, they get rounded to single-precision reals! This means that you only get about 6 digits of precision, even for integer values.
I found this out the hard way when trying to figure out why time() values would work fine until I relogged. I kept getting timed events that were way off. I finally noticed that all the time() values were getting rounded off. These are 10-digit numbers, so after reloading, the last 4 digits get set to 0! This means that timestamps can be off by over an hour!
The solution is to store it as a string with tostring() and reload it with tonumber(), but it can be a pain to mess with if you aren't careful.[ post edited by Sli ]
|