I have an 8-byte array in my application with this data:
00000133339e36a2
This data represents a long (on the platform the data was written in, on a Mac this would be a long long) with the value of
1319420966562
In the actual application this is a semi-randomized set of data, so the number will always be different. Therefore, I need to convert the byte array into a printable long long.
I've tried casting the data directly into a long long, but I came up with
1305392
where I should have been seeing the above number.
For those of you with more experience in C byte manipulation than I do, how would I correctly convert a byte array to a long long?
EDIT: Strangely, all of your solutions keep outputting the same number: 866006690. That is the decimal equivalent of the last four bytes of the data.
This seems one of the (rare) situations where an union is useful:
union number
{
char charNum[16];
long long longNum;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With