Millisecs() and highest integer value

Blitz3D Forums/Blitz3D Programming/Millisecs() and highest integer value

Marcell(Posted 2006) [#1]
Hello.

Millisecs() gives the clock value as integer.
Is there built in check in Millisecs() for situation
where the highest integer is reached and
the value must start from zero (0) again?

Thanks.


markcw(Posted 2006) [#2]
afaik no. instead Millisecs() will go to a negative value when the integer value is too high, so if you really want to you can take this into consideration when programming.


Ross C(Posted 2006) [#3]
It's summit like 2147483648 ( 2 ^ 31) i THINK.


Matty(Posted 2006) [#4]
It takes about 24/25 days to go beyond the upper limit so is rather unlikely for most games for this to matter.


GfK(Posted 2006) [#5]
It takes about 24/25 days to go beyond the upper limit so is rather unlikely for most games for this to matter.
...unless you leave your PC on 24/7 (one of mine is).

Millisecs() reports the system uptime - not the time elapsed since your game was run.


jfk EO-11110(Posted 2006) [#6]
It is still unlikely that the user will run the game just in the minutes or hour the timer will flip to the neative min of the signed 32 bit number. However, likelyhood shound not be a criterium for good programmers. Simply check if millisecs is lower than the previous millisecs value, and if so, do the required steps.

the highest and lowest values of this signed 32 Bit int are:
2147483647
-2147483648

Or in binary:
%01111111111111111111111111111111
%10000000000000000000000000000000

The very first bit from the left side controls the interpretation of the int. If it's set, then it's a negative number, beginning at the min (-2147483648), plus the normal binary value of the other 31 bits.

For delta timing code you will not have to do special steps, because eg:
ms_now=%100000000000000000000000000001111
ms_old=%01111111111111111111111111110000
print ms_now-ms_old

ms_old was taken 16 millisecs before the counter was reset, ms_now 15 milliseconds after it was reset. the diffrence is still 31 Millisecs. So (-2147483632) - 2147483633 is 31.


Marcell(Posted 2006) [#7]
Thanks, I myself leave my computer often running for many days.


Zethrax(Posted 2006) [#8]
Here's some more info on the subject.

http://www.blitzbasic.com/Community/posts.php?topic=52877#591055