union test {
double d;
char c[8];
};
How would i display the double d () byte by byte using the char c[8]?
Thanks in advance...
Union Troubles!
Using the this union:
I assume you want to display them as hex? try this:
BTW, I tried to do this using cout <<...but I couldn't. I suck with streams.
Actually, I'm not sure how a double is packed in memory, so you may want to reverse the order of those bytes. Or they maybe be swapped around some other way. Something you could play with, I'm sure.
Edited by - Stoffel on July 25, 2000 1:11:48 PM
printf ("0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n", u.c[0], u.c[1], u.c[2], u.c[3], u.c[4], u.c[5], u.c[6], u.c[7]);
BTW, I tried to do this using cout <<...but I couldn't. I suck with streams.
Actually, I'm not sure how a double is packed in memory, so you may want to reverse the order of those bytes. Or they maybe be swapped around some other way. Something you could play with, I'm sure.
Edited by - Stoffel on July 25, 2000 1:11:48 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement