[Haskell-cafe] Endian conversion

Tomasz Zielonka tomasz.zielonka at gmail.com
Tue Oct 4 01:31:28 EDT 2005

On 10/3/05, Udo Stenzel <u.stenzel at web.de> 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
> all.

Exactly! Network encodings for integers are precisely, mathematically
defined. Surprisingly, it is very difficult to see (it was a revelation for
too). Perhaps the reason is that people get used to the mess in C
networking code.

Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org//pipermail/haskell-cafe/attachments/20051004/60381305/attachment.htm

More information about the Haskell-Cafe mailing list