Sys.getTimer() can be negative

This isn't so much a bug but rather people should be aware that Sys.getTimer() can return a negative number. It returns a value of type Number, which is a 32 bit signed value. Generally this starts counting at zero when the device is rebooted. After about 25 days, this will wrap and become negative. (2^31)/60/60/24/1000=days.

I'm just mentioning it because I had a couple bugs where I assumed Sys.getTimer() was always >= 0, not to mention kept getting larger.

It's the sort of bug that can be really difficult to track down as it appears totally random and not easily reproducible if you aren't aware of it.
  • Interesting comment on a 7 year old thread. However it's definitely documented:

    "Note:

    The returned value typically starts at zero on device boot and will roll over periodically. Assuming the timer starts at zero, this will happen ~25 days after a reboot, and every ~50 days thereafter."

    While it doesn't explicitly says negative, if you read between the lines it's there.