On 2015-12-08 22:48, Maarten de Vries wrote:
On 8 December 2015 at 22:14, Martin Vymazal
wrote: Hi,
ok, here's the whole story. We have a code that computes some data, compresses them through zlib and saves as binary. We also use our own utility to postprocess the compressed file and convert it to human-readable format.
What happened recently is that the code ran on a big-endian machine and since zlib preserves the endian-ess of the data, it generated a binary with big-endian doubles. We would like to have the possibility of bringing that file on a little-endian machine (say user's laptop) and postprocess there, instead of doing everything on the big-endian machine. Do you have an alternative suggestion how to approach this problem? Let's assume that writing the output data in any other format than the current one is not possible.
I am also still interested in knowing whether boost (1.59) supports conversions between endian representations of floating-point values.
If you absolutely must, the easiest way to do this is to read the data as if it's an unsigned integer type (of the correct size), convert endianness, then reinterpret_cast (or something similarly horrible) to the floating point type.
Of course, not relying on the platform specific bit representation of primitive data types when serializing data is a much better idea.
-- Maarten
What would be a possible approach to save the data without 'relying on the platform specific bit representation of primitive data types' as you put it? I can not save the data as plain ascii text, because the files would simply be huge (the're already big as they are). Is there some more intelligent solution? I'm not a software engineer, so I'd be happy to hear what is the common practice here. I will also try one last time: does boost support conversion of floating point types or not? The website says so, but it doesn't work for me. I am not asking because I plan to use this functionality, I'm simply curious since I already started playing with it. Martin
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users