// https://forum.arduino.cc/t/splitting-a-long-long-int/1225989/2?u=dougp
long long _64BitA = 0x501B2772D4D400AA;
long long _64BitB;
long long _64BitC;
void setup() {
Serial.begin(115200);
fileInfo();
//Serial.println(sizeof(_64BitA)); /// prints '8'
unsigned long upper32, lower32, swap32;
upper32 = _64BitA >> 32;
// memcpy(&lower32, &_64BitA, 4);
lower32=_64BitA & 0xFFFFFFFF;
Serial.print("upper 32 bits \t");
Serial.println(upper32, HEX);
Serial.print("lower 32 bits \t");
Serial.println(lower32, HEX);
// All bits now extracted to 32-bit variable
// swap values
swap32 = upper32;
upper32 = lower32;
lower32 = swap32;
// place back in 64-bit
_64BitC = upper32;
_64BitB = _64BitB | _64BitC << 32;
_64BitB |= lower32;
// extract again and pring new values
upper32 = _64BitB >> 32;
//memcpy(&lower32, &_64BitB, 4);
lower32=_64BitB & 0xFFFFFFFF;
Serial.print("upper 32 bits \t");
Serial.println(upper32, HEX);
Serial.print("lower 32 bits \t");
Serial.println(lower32, HEX);
}
void loop() {
// put your main code here, to run repeatedly:
}
void fileInfo() {
/*
Print file name + time and date of printing
*/
Serial.println();
Serial.println(__FILE__);
Serial.print(__TIME__);
Serial.print(" hrs\t");
Serial.println(__DATE__);
Serial.println();
}