Recording/Reading C doubles in the IEEE 754 interchange format
Posted
by rampion
on Stack Overflow
See other posts from Stack Overflow
or by rampion
Published on 2010-04-23T19:45:50Z
Indexed on
2010/04/23
23:23 UTC
Read the original article
Hit count: 416
So I'm serializing a C data structure for cross-platform use, and I want to make sure I'm recording my floating point numbers in a cross-platform manner.
I had been planning on just doing
char * pos;
/*...*/
*((double*) pos) = dataStructureInstance->fieldWithOfTypeDouble;
pos += sizeof(double);
But I wasn't sure that the bytes would be recorded in the char *
array in the IEEE 754 interchange format. I've been bitten by cross-platform issues before (endian-ness and whatnot). Is there anything I need to do to a double
to get the bytes in interchange format?
© Stack Overflow or respective owner