Calmatory
November 1st, 2008, 04:06 PM
So, I am a bit lost, confused and frustrated thus I am not sure do I even know what I am asking/writing about but here it goes:
As you should already know, gettimeofday puts seconds + microseconds since 1st of jan 1970 to the timeval struct.
Now, I have the seconds + microseconds since that date, but how on earth can I use them to measure time differences between two sets of seconds + microseconds?
The seconds value is huge(billion or so), and I am a bit concerned about dealing with it. 16-bit unsigned int should have boundaries of 65536 or so, so what is the way to deal with the value?
Storing two that huge values and getting the delta seconds, then delta microseconds and doing some calculation does not seem the best way. What I'd think as better way would be to trim the seconds value down and deal with the smaller values instead. How do I accomplish this? How do I convert from e.g. 40 seconds and 493294 microseconds to milliseconds?
Yes, I could multiply the seconds with 1000 to get the milliseconds and then divide the microseconds with 1000 to get milliseconds and try to measure the delta from that, but 1000 billion... :drool:
I tried googling, with no help. I thought this would be better place to ask rather than use IRC.
As you should already know, gettimeofday puts seconds + microseconds since 1st of jan 1970 to the timeval struct.
Now, I have the seconds + microseconds since that date, but how on earth can I use them to measure time differences between two sets of seconds + microseconds?
The seconds value is huge(billion or so), and I am a bit concerned about dealing with it. 16-bit unsigned int should have boundaries of 65536 or so, so what is the way to deal with the value?
Storing two that huge values and getting the delta seconds, then delta microseconds and doing some calculation does not seem the best way. What I'd think as better way would be to trim the seconds value down and deal with the smaller values instead. How do I accomplish this? How do I convert from e.g. 40 seconds and 493294 microseconds to milliseconds?
Yes, I could multiply the seconds with 1000 to get the milliseconds and then divide the microseconds with 1000 to get milliseconds and try to measure the delta from that, but 1000 billion... :drool:
I tried googling, with no help. I thought this would be better place to ask rather than use IRC.