Safe Haskell | None |
---|---|
Language | Haskell2010 |
Bit indexable types
Documentation
class IndexableBits a where Source #
Type whose bits are indexable
Nothing
bit i
is a value with the i
th bit set and all other bits clear.
bit :: (Num a, ShiftableBits a) => Word -> a Source #
bit i
is a value with the i
th bit set and all other bits clear.
setBit :: a -> Word -> a Source #
x `setBit` i
is the same as x .|. bit i
setBit :: Bitwise a => a -> Word -> a Source #
x `setBit` i
is the same as x .|. bit i
clearBit :: a -> Word -> a Source #
x `clearBit` i
is the same as x .&. complement (bit i)
clearBit :: (FiniteBits a, Bitwise a) => a -> Word -> a Source #
x `clearBit` i
is the same as x .&. complement (bit i)
complementBit :: a -> Word -> a Source #
x `complementBit` i
is the same as x `xor` bit i
complementBit :: Bitwise a => a -> Word -> a Source #
x `complementBit` i
is the same as x `xor` bit i
testBit :: a -> Word -> Bool Source #
Return True
if the n
th bit of the argument is 1
testBit :: (Bitwise a, Num a, Eq a) => a -> Word -> Bool Source #
Return True
if the n
th bit of the argument is 1
popCount :: a -> Word Source #
Return the number of set bits
popCount :: (Bitwise a, Num a, Eq a) => a -> Word Source #
Return the number of set bits