Best way to handle System.currentTimeMillis() to fp format

Put your problem here if it does not fit any of the other categories.

Best way to handle System.currentTimeMillis() to fp format

Postby Skywhy » Sun Dec 27, 2009 1:09 pm

Like the topic of the thread says. In my game I would like to turn all the calculations into FP format. I can eliminate pretty much everything else but I still need to do the the following calculation in long format.

Code: Select all
long t = this.lastUpdateTime - System.currentTimeMillis();


The value I get from this is the time passed since last frame, which is like.. two digit millisecond value, which naturally is more than good for FP stuff. After that calculation I turn the resulting value into FP integer and use it with the rest of my calculations but I'd like to get rid of that long calculation too. Any ideas how to go around this to do it in FP format?

I mean, I'm pretty sure I cannot just go and do a normal conversion to FP format in this style:
Code: Select all
int fpT = t * (1<<16);

because there is always the change that it'll overflow and as the numbers that System.currentTimeMillis() give out are BIG.

So any advice how to keep the same "accuracy" of the timer but get rid of the long calculation and have it replaced with nice and fast FP calculation. Any advices on how to trim down the System.currentTimeMillis() or what ever to get around this are greatly appreciated.

Cheers guys.


// SkyWhy
Skywhy
Developer
Developer
 
Posts: 35
Joined: Tue Oct 20, 2009 7:55 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 21 guests