
Disclaimer: I'm a beginner too.
That's essentially what I've resorted to as well. It would be nice to
see standard functions that pull out specific bits of a word, or join
them together; I've been doing them with shifts and ORs as well. I'd
also be interested in knowing if there's a more respected way of doing
this.
As an aside, the Crypto library on Hackage has an embedded library
called Data.LargeWord, which offers Word64, Word128 and Word256
variants in case you need them (though there is (currently) a bug with
right-shifts on these larger words).
On Thu, May 20, 2010 at 3:36 PM, Daniel Rozycki
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
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners