mardi 2 août 2016

How to split 64-integer into 2 32-bit integers?

Good day! I have already looked for solution of my problem, but I couldn't find any… At least all proposed solutions don’t work for me… Or I do smth wrong…

I have 64-bits integer:

{uint64_t st0 = 1470134824450120;}

I would like to get only the last 8-digits of this number, i.e. 24450120

I did for that the following:

uint32_t timestamp1 = 0;
uint32_t timestamp2 = 0;

timestamp2 = (uint32_t) st0;
timestamp1 = st0 >> 32;

printf("input:    %" PRIu64 "\n", st0);
printf("unpacked: %" PRIu32 " %" PRIu32 "\n", timestamp2, timestamp1);

As the result I have got:

input:    1470134824450120
unpacked: 1878767688 342292

What is wrong here?

Please, help me… I am not a student at university, I haven’t any advisor to help me…

Aucun commentaire:

Enregistrer un commentaire