0

Hi, we have the following problem:
We have a code that uses the "GetTickCount" method (the return value is the number of milliseconds that have elapsed since the system was started).
The Problem:
Since GetTickCount returns only a 32-bit number, after about 49 days, the counter wraps.
The solution we thoung is the following:
Use the "COleDateTime::GetCurrentTime", but the problem is that this method returns the value for example like: 9411.22222 (double variable)
and we need the value in DWORD so when we set the value in the variable we lost all the date after the '.', we will receive the value "9411".
Any Ideas?
How to resolve this?
Thanks :eek:

3
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by ~s.o.s~
0

You could set up another variable that increments each time your value wraps. That effectively gives you a 64bit counter. This of course would require some minor redesign every time your counter is accessed in the code.

0

Thanks for the qick answers:
1. We prefer not use external libraries, but thanks
2. What do you mean "This of course would require some minor redesign every time your counter is accessed in the code"?
Thanks again

0

What do you mean "This of course would require some minor redesign every time your counter is accessed in the code"?

I think what Mr. WaltP means is that when you have to get the actual value of the counter you have to take into consideration the current "counter" value as well as the "number_of_times_counter_overflowed".

For eg.
If current counter value = 12324 and it has already overflowed 2 times then the actual counter value can be obtained by:

actual_counter = counter + overflow_times * MAX_COUNTER_VALUE ;

But its just what i think, for the actual theory you will have to wait till he again comes online :D

Hope it helped, bye.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.