Safe Haskell | None |
---|---|
Language | Haskell2010 |
Operations on bits
- module Haskus.Format.Binary.Bits.Basic
- class BitReversable w where
- reverseBitsGeneric :: (FiniteBits a, Integral a) => a -> a
- reverseLeastBits :: (FiniteBits a, BitReversable a) => Word -> a -> a
- makeMask :: FiniteBits a => Word -> a
- maskLeastBits :: FiniteBits a => Word -> a -> a
- bitsToString :: FiniteBits a => a -> String
- bitsFromString :: Bits a => String -> a
- getBitRange :: (BitReversable b, FiniteBits b) => BitOrder -> Word -> Word -> b -> b
- bitOffset :: Word -> Word
- byteOffset :: Word -> Word
Basic
Bit reversal
reverseBitsGeneric :: (FiniteBits a, Integral a) => a -> a Source #
Reverse bits in a Word
reverseLeastBits :: (FiniteBits a, BitReversable a) => Word -> a -> a Source #
Reverse the n
least important bits of the given value. The higher bits
are set to 0.
Mask
makeMask :: FiniteBits a => Word -> a Source #
makeMask 3 = 00000111
maskLeastBits :: FiniteBits a => Word -> a -> a Source #
Keep only the n least-significant bits of the given value
String conversion
bitsToString :: FiniteBits a => a -> String Source #
Convert bits into a string composed of '0' and '1' chars
bitsFromString :: Bits a => String -> a Source #
Convert a string of '0' and '1' chars into a word
Shift
getBitRange :: (BitReversable b, FiniteBits b) => BitOrder -> Word -> Word -> b -> b Source #
Take n bits at offset o and put them in the least-significant bits of the result