uint64 value = 0x543;
double dval = *reinterpret_cast<double*>(&value);
I want dval to be of a certain value which when written in hexadecimal looks like this "0x543". Is there any danger doing this? Do you see a more efficient way of doing this?
Thanks
CodePudding user response:
Use std::bit_cast
. In fact, the shown example is exactly what you are trying to do.