[Haskell-cafe] Endian conversion
john at repetae.net
Tue Oct 4 20:40:34 EDT 2005
On Mon, Oct 03, 2005 at 09:33:11PM +0200, Udo Stenzel wrote:
> Joel Reymont wrote:
> > Are there any endian conversion routines for Haskell? I'm looking to
> > build binary packets on top of NewBinary.Binary but my data is coming
> > in little-endian whereas I'll need to send it out big endian.
> Why don't you pull out 4 bytes and assemble them manually? Three
> shifts, logical ors and fromIntegrals aren't that much of a burden after
Yeah, this is exactly the right approach, just pull out the bytes with a
shift and bitwise and, and then send them in one order or the other.
there is no need to know the endianess of the architecture the program
is running on.
John Meacham - ⑆repetae.net⑆john⑈
More information about the Haskell-Cafe