So, I am serializing the C data structure for cross-platform use, and I want to make sure that I write my floating-point numbers in a cross-platform manner.
I planned to just do
char * pos; /*...*/ *((double*) pos) = dataStructureInstance->fieldWithOfTypeDouble; pos += sizeof(double);
But I was not sure that the bytes would be written in an array char *in the IEEE 754 interchange format. I was bitten by cross-platform questions before (endian-ness and whatnot). Is there anything I need to do in doubleorder to receive bytes in an exchange format?
char *
double
C IEEE 754 , , double, .
, , IEEE 754, ( , - - !)... , ( , , , 0x12345678 0x12 0x78 ).
( , , , sprintf() strtod(), , , , , 5.2.4.2.2 C99.)
sprintf()
strtod()
Source: https://habr.com/ru/post/1742527/More articles:How does Diffie-Hellman cryptography work with elliptic curve? - elliptic-curveHow can I parse_url in PHP when there is a url in a string variable? - urlProper thread termination in a multithreaded C # application - multithreadingМогу ли я заставить psycopg2 работать с Windows с помощью python, созданного с помощью vc9? - pythonHow to deal with multiple screens + dynamic controls in Android? - androidTwitter widget stops page from rendering in IE 8, does anyone know why? - javascriptDecorator module standard - pythonProviding LaTeX on third-party sites? - firefoxAjaxtoolkit TextboxWatermarkExtender: как изменить текст из Javascript - asp.netСайт Sharepoint с использованием PHP-кода - sharepointAll Articles