Safe Haskell | None |
---|
This module provides strict (low and high halves are unpacked) signed and unsigned binary word data types of sizes 96, 128, 160, 192, 224, and 256 bits.
- class Bits w => BinaryWord w where
- type UnsignedWord w
- type SignedWord w
- unsignedWord :: w -> UnsignedWord w
- signedWord :: w -> SignedWord w
- unwrappedAdd :: w -> w -> (w, UnsignedWord w)
- unwrappedMul :: w -> w -> (w, UnsignedWord w)
- leadingZeroes :: w -> Int
- trailingZeroes :: w -> Int
- allZeroes :: w
- allOnes :: w
- msb :: w
- lsb :: w
- testMsb :: w -> Bool
- testLsb :: w -> Bool
- class BinaryWord w => DoubleWord w where
- type LoWord w
- type HiWord w
- loWord :: w -> LoWord w
- hiWord :: w -> HiWord w
- fromHiAndLo :: HiWord w -> LoWord w -> w
- extendLo :: LoWord w -> w
- signExtendLo :: SignedWord (LoWord w) -> w
- data Word96 = Word96 !Word32 !Word64
- data Word128 = Word128 !Word64 !Word64
- data Word160 = Word160 !Word32 !Word128
- data Word192 = Word192 !Word64 !Word128
- data Word224 = Word224 !Word96 !Word128
- data Word256 = Word256 !Word128 !Word128
- data Int96 = Int96 !Int32 !Word64
- data Int128 = Int128 !Int64 !Word64
- data Int160 = Int160 !Int32 !Word128
- data Int192 = Int192 !Int64 !Word128
- data Int224 = Int224 !Int96 !Word128
- data Int256 = Int256 !Int128 !Word128
Documentation
class Bits w => BinaryWord w whereSource
Extra bit-manipulation functions for binary words of fixed length.
unsignedWord :: w -> UnsignedWord wSource
Convert the word to the unsigned type (identical to fromIntegral
)
signedWord :: w -> SignedWord wSource
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 -> IntSource
Number of leading (from MSB) zero bits
trailingZeroes :: w -> IntSource
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
class BinaryWord w => DoubleWord w whereSource
Defines a particular way to split a binary word in halves.
The low half of the word
The high half of the word
fromHiAndLo :: HiWord w -> LoWord w -> wSource
Construct a word from the low and high halves
extendLo :: LoWord w -> wSource
Extend the low half
signExtendLo :: SignedWord (LoWord w) -> wSource
Sign-extend the low half