void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
double d = 0.1; // 64 bits double on ESP32 represented with 0x3FB999999999999A in IEEE format
int64_t n; // 64 bits integer
n = *reinterpret_cast<std::int64_t*>(&d); // attempting to copy the 8 bytes from our double into our integer by dereferencing a pointer ➜ Undefined behavior
Serial.print("n = 0x");
Serial.println(n, HEX);
memcpy(&n, &d, sizeof d); // attempting to copy the 8 bytes from our double into our integer with memcpy ➜ fine
Serial.print("n = 0x");
Serial.println(n, HEX);
}
void loop() {}