Boost logo

Boost Users :

From: Ákos Maróy (akos_at_[hidden])
Date: 2008-08-11 03:24:16


Andrea Denzler wrote:
> Most modern platforms use the IEEE 754 (1985) encoding for binary data
> (float/double). But I suppose there is still the (easy to handle) endianess
> issue. http://www.appinf.com/download/FPIssues.pdf

and how would I go about handling the endianness issue? is there a
compile-time define in boost already that signals endianness of floating
point types? or is the endiannes of the floating point types the very
same as for integer types?

I was looking at the implementation of the Qt class QDataStream, which
serves a similar purpose. What they simply do is that they store the 4
bytes for floats in big endian order (swap if the system is little
endian). for doubles, they have a more elaborate mapping, handling four
cases:

- normal little endian format
- swapped little endian format
- normal big endian format
- swapped big endian format

their test is rather simple - they take a number that has a double
representation equivalent of the character array:

"0123ABCD0123ABCD\0\0\0\0\0\0\0"

in normal little endian format, and then use the pattern resulting on
the target system to determine the format of the system itself. but this
has to be done at compile time.

my question is: is there some similar, compile / configure time test for
boost available already, which result I could use to add float and
double support to the portable_binary_archive class, thus making it
complete? or do I have to implement my own tests for this purpose? (this
would add complexity to my project, as so far I myself don't have
configure-time tests at all, but depend on boost and similar libraries
to already provide me with target platform details).

Akos


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net