[Haskell-beginners] Bit Manipulation
Daniel Rozycki
daniel.rozycki at yale.edu
Thu May 20 15:36:02 EDT 2010
Hi all,
I am a newcomer to Haskell trying to manipulate data at the bit level. More
specifically, I am trying to calculate a seven-bit value and a nine-bit
value, concatenate the two values as a Word16, and put the result using
putWord16. I know that this sounds weird (because it totally is), but it is
required by the standard of a networking protocol that I am implementing.
The byte seems to be the atomic unit in Haskell, but I need to go subatomic.
Currently, I am storing the two values each as Word16s, bitshifting one of
them left by nine (using shift in the Data.Bits module), and then adding the
two. Is there a simpler and/or more elegant way of achieving this result?
Thanks,
Dan Rozycki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100520/fa6d9fda/attachment.html
More information about the Beginners
mailing list