On Tue, 2006-03-14 at 00:21 +0100, fons adriaensen wrote: > On Mon, Mar 13, 2006 at 11:59:15PM +0100, stefan kersten wrote: > > > as paul stated, network byte order is defined to be > > big-endian, so yes, you have to convert 32 bit floats (and > > doubles, for that matter) on intel, because they are stored > > lsb first. of course it would be perfectly valid for netjack > > to use little endian `on the wire'; but this would be like > > putting my powerbook in little endian mode when playing a > > wav file. sort of. > > OK, but for floats the situation could be more complex. On Intel, > the exponent/sign byte is the last one. Is it always the first > one on BE platforms ? If it isn't then using ntohl() or htonl() > wich are designed to work on 32-bit ints will not help. > > For doubles, things are even more fuzzy. Can you just use ntohl() > and htonl() on both halves, or do these two have to be swapped as > well ? Will either rule produce consistent results on all > platforms ?
i don't believe that "network order" is defined for floats, but one could reasonably assume it was the same big-endian ordering. however, since the IEEE spec crosses 8 bit boundaries (IIRC), simply using *to* isn't going to work. i think this applies also to doubles. ntohf and htonf would be required, i think.
