How can I access Bytes (8) in a double Variable. I need to access all 8 Bytes of a double. I need to convert each Byte of the double to an Hex-Value (String).
Printable View
How can I access Bytes (8) in a double Variable. I need to access all 8 Bytes of a double. I need to convert each Byte of the double to an Hex-Value (String).
double value = 123.456F;
char* ptr = (char *)&value;
But how can I access for example the 3rd Byte?
double value = 123.456F;
unsigned char* ptr = (unsigned char *)&value;
// now you can treat the double as if it were any other array of char bytes
unsigned char third_byte = ptr[2];