Boost logo

Boost :

Subject: Re: [boost] [boost::endian] Request for comments/interest (floating point endian handling)
From: Tomas Puverle (tomas.puverle_at_[hidden])
Date: 2010-05-28 11:05:43


> double val1 = someVal; // little endian, for example
> // ...
> double val2 = little_endian_cast<double>(big_endian_cast<double>(val1));
>
> For many values, val1 != val2; (For all integral types in the above casting
> functions, all possible values will have val1 == val2.)

This is a good point. And this is not as unusual as you may think, even on
IEEE 754 machines. For example, on some compilers on Intel machines,
sizeof(long comes in at 12 bytes (even though long double is only 80 bits),
essentially meaning that the last two bytes are garbage when the data is in
memory.

However, I am not completely sure that this falls within the realm of an endian
library. If, as in your example, the program cannot move the data from its
internal registers to memory without modifying it, what would you suggest the
endian should library do?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk