timestamp question

W

wongjoekmeu

Hello all,

I have a C++ program ( I am not sure if this is the right place to
post this question ), One of the function returns two unsigned
integers which are referred to be TimestampLo and TimestampHi. Can
anyone please help me out how I am supposed to convert these two
integer to an understandable timestamp. It says also for the
TimestampLo variable that this is the lower 32-bits and for the
TimestampHi variable is the higher 32-bits. What does that mean ? And
how do I construct the timestamp ? Thanks. If this is not the right
place to post this question can anyone please give me some suggestion
where I could post this ?

rr
 
E

Erik Wikström

Hello all,

I have a C++ program ( I am not sure if this is the right place to
post this question ), One of the function returns two unsigned
integers which are referred to be TimestampLo and TimestampHi. Can
anyone please help me out how I am supposed to convert these two
integer to an understandable timestamp. It says also for the
TimestampLo variable that this is the lower 32-bits and for the
TimestampHi variable is the higher 32-bits. What does that mean ?

It means that the two integers are the two halves of one big (64-bit)
integer. TimestampLo contains bits 0-31 or the timestamp and TimestampHi
contains bits 32-63
And how do I construct the timestamp ?

Put them back into a 64-bit integer (probably a long or a long long on
your platform, if you can use the uint64_t type to be sure). You can use
shifting and binary or to create the original timestamp like this:

uint64_t ts = TimestampHi;
ts = ts << 32;
ts = ts | TimestampLo;

Make sure that the 64-bit variable is unsigned.
 
J

James Kanze

It means that the two integers are the two halves of one big
(64-bit) integer. TimestampLo contains bits 0-31 or the
timestamp and TimestampHi contains bits 32-63
Put them back into a 64-bit integer (probably a long or a long
long on your platform, if you can use the uint64_t type to be
sure). You can use shifting and binary or to create the
original timestamp like this:
uint64_t ts = TimestampHi;
ts = ts << 32;
ts = ts | TimestampLo;
Make sure that the 64-bit variable is unsigned.

Which still only gives you an integral value. What that
integral value means depends on the system, and he really needs
to look at the system documentation for that. (In this case,
the system also contains various functions for manipulating or
converting the original format. The only reason I can think of
for converting to uint64_t is to convert it to a standard
time_t, in which case, you'll have to follow up with a few
additional steps.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top