problem calculating time

Blitz3D Forums/Blitz3D Programming/problem calculating time

Floats behave a bit strange:
x# = 0

For i = 1 To 1000
x# = x# + 0.0001
Next

Print x

WaitKey()
End

They are only as exact as they need to be. In the code above, it is precise until 0.0001 digits. All the stuff after that is just "rubbish". I believe it has something to do that inside the CPU floats are just integers as well.

Then in the graphical routine, it takes time to render each frame. So if you check the Millisecs() once a loop, it will not check every millisecond. Say the program renders at 30 FPS, then the loop repeats at 30FPS, so the "exit timer" checks at 30FPS, too. There is a deviation of one frame allways. The only thing you can do about this is check the exit timer more often.