| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
HaskellWorks.Data.Bits.Broadword.Word32
Documentation
Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16, 32 } such that the highest bit is set to 1 and all other bits are cleared.
>>>import Numeric(showHex)>>>showHex (h 2) """aaaaaaaa">>>showHex (h 4) """88888888">>>showHex (h 8) """80808080">>>showHex (h 16) """80008000">>>showHex (h 32) """80000000"
Initialise all sub-words of size k where k ∈ { 2, 4, 8, 16, 32 } such that the lowest bit is set to 1 and all other bits are cleared.
>>>import Numeric(showHex)>>>showHex (l 2) """55555555">>>showHex (l 4) """11111111">>>showHex (l 8) """1010101">>>showHex (l 16) """10001">>>showHex (l 32) """1"
kBitDiff :: Int -> Word32 -> Word32 -> Word32 Source #
Broadword subtraction of sub-words of size k where k ∈ { 2, 4, 8, 16, 32 }.
The subtraction respects 2's complement so sub-words may be regarded as signed or unsigned words.
>>>import Numeric(showHex)>>>showHex (kBitDiff 8 0x04030201 0x02020101) """2010100">>>showHex (kBitDiff 8 0x04030201 0x01020304) """301fffd">>>showHex (kBitDiff 8 0x200000ff 0x100000ff) """10000000"
kBitDiffPos :: Int -> Word32 -> Word32 -> Word32 Source #
Broadword subtraction of sub-words of size k where k ∈ { 2, 4, 8, 16, 32 } where results are bounded from below by 0.
>>>import Numeric(showHex)>>>showHex (kBitDiffPos 8 0x04030201 0x02020101) """2010100">>>showHex (kBitDiffPos 8 0x04030201 0x01020304) """3010000">>>showHex (kBitDiffPos 8 0x200000ff 0x100000ff) "" -- produces nonsense in the last sub-word"10000000"
kBitDiffUnsafe :: Int -> Word32 -> Word32 -> Word32 Source #
Broadword subtraction of sub-words of size k where k ∈ { 2, 4, 8, 16, 32 } where all the sub-words of x and y must
not have the signed bit set for the result to be meaningful.
>>>import Numeric(showHex)>>>showHex (kBitDiffUnsafe 8 0x04030201 0x02020101) """2010100">>>showHex (kBitDiffUnsafe 8 0x04030201 0x05060708) """fffdfbf9">>>showHex (kBitDiffUnsafe 8 0x200000ff 0x100000ff) """10000080"