This question has probably being asked, but I searched and could not find the answer.
I'm implementing a toy virtual machine, where the OpCodes take the form:
std::tuple<int8_t, int64_t, int64_t> // instruction op1, op2
I'm trying to pack a double into one of the operands and read it back again when processing it. This doesn't work reliably.
double d = ...
auto a = static_cast<int64_t>(d);
auto b = static_cast<double>(a)
// sometimes, b != d
Is there a way to pack the bit representation of the double into an int64_t, and then read that bit pattern back get the same exact double as before?