Reputation: 587
Is it possible to read a 5-byte segment of data into a Word64
using the binary
package, leaving the three higher-order bits empty? Or must I use a ByteString
?
Upvotes: 2
Views: 213
Reputation: 3081
Shift and bitwise-OR are in Data.Bits. Data.Binary.Get has a family of getWord functions that read fixed-length pieces from a ByteString
of unknown length, without any interpretation beyond endian-ness. It may also help to know that fromIntegral
for Word
types preserves the unsigned-int interpretation of the Word (when going from smaller to larger words), so you can zero-extend a Word8
to a Word64
.
Upvotes: 1