Does anyone know of a library that provides a function that performs this logic or perhaps a method to perform this logic?
I'm trying to convert:
unsigned char test[] = "\x00\x00\x56\x4b\x7c\x8a\xc5\xde";
to:
94882212005342 / 0x0000564b7c8ac5de
I'm aware I could loop over each individual byte in test and utilize sprintf to convert each byte to string and concatenate them into a buffer with strcat and convert the buffer string to unsigned long long via strtoull. However I'm looking for something more comprehensive and simple. Is there such a way?
It's just maths.
Remember to cast to type wide enough before shifting.
You have 8 values:
which in the decimal is:
and you want to have:
which is:
It's a mathematical operation. You could write ex
test[0] * 72057594037927936ullbut that's less readable thentest[0] << 56.