Was that really supposed to be a "%"? The modulo (remainder) operator?

05.06.2010 2:56 пользователь "Anthoni" <anthoni.gard...@gmail.com> написал:

Hello,

So I've been struggling with this and I am not sure why because it
should be simple, but for some reason I just can not get my head
around it !!

I am developing a game and when the user saves their game, I write out
the last time I checked their stats using System.currentTimeMillis().
Then when they load in the game I want to see how many total seconds
have elapsed since it was last saved. Naturally I thought of getting
System.currentTimeMillis() and then deducting my saved value and then
converting that into seconds using this :=

long timePassed = System.currentTimeMillis() - lastCheck;
int seconds = (int) ((timePassed / 1000) % 60);

But on each load the seconds keep altering, but not within the right
bounds. For example on one load it comes as 59 seconds, then it showed
23 seconds etc. Obviously my algorithm is slightly wonky but I can't
work out why.

Could some one please elaborate where I am going ?

Regards
Anthoni

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to