Safe Haskell | None |
---|---|
Language | Haskell2010 |
Extra operations on binary words of fixed length.
- class (FiniteBits w, FiniteBits (UnsignedWord w), FiniteBits (SignedWord w)) => BinaryWord w where
- type UnsignedWord w
- type SignedWord w
- lMsb :: (Functor f, BinaryWord w) => (Bool -> f Bool) -> w -> f w
- lLsb :: (Functor f, BinaryWord w) => (Bool -> f Bool) -> w -> f w
Documentation
class (FiniteBits w, FiniteBits (UnsignedWord w), FiniteBits (SignedWord w)) => BinaryWord w where Source #
Two's complement, fixed length binary words.
unsignedWord, signedWord, unwrappedAdd, unwrappedMul, leadingZeroes, trailingZeroes, allZeroes, allOnes, msb, testMsb, setMsb, clearMsb
type UnsignedWord w Source #
The unsigned variant type
type SignedWord w Source #
The signed variant type
unsignedWord :: w -> UnsignedWord w Source #
Convert the word to the unsigned type (identical to fromIntegral
)
signedWord :: w -> SignedWord w Source #
Convert the word to the signed type (identical to fromIntegral
)
unwrappedAdd :: w -> w -> (w, UnsignedWord w) Source #
Unwrapped addition
unwrappedMul :: w -> w -> (w, UnsignedWord w) Source #
Unwrapped multiplication
leadingZeroes :: w -> Int Source #
Number of leading (from MSB) zero bits
trailingZeroes :: w -> Int Source #
Number or trailing (from LSB) zero bits
The word with all bits set to 0
The word with all bits set to 1
The word with MSB set to 1 and all the other bits set to 0
The word with LSB set to 1 and all the other bits set to 0
Test if the MSB is 1
Test if the LSB is 1
Set the MSB to 1
Set the LSB to 1
Set the MSB to 0
Set the LSB to 0