#include <iostream>
using namespace std;
template<class T>
T fromBigEndin(uint8_t *buf) {
T number = 0;
uint8_t nBytes = sizeof(T);
uint8_t i;
for (i = 0; i < nBytes; i += 1) {
number += buf[i] << (16 * (nBytes - i - 1));
}
return number;
}
int main()
{
uint8_t uid[] = {0x00, 0x12, 0x00, 0x00, 0x34, 0x00, 0x59, 0xAF};
int64_t uidNbr = fromBigEndin<int64_t>(uid);
cout<<uidNbr;
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: