Safe Haskell | None |
---|---|
Language | Haskell2010 |
Bit shifts
Synopsis
- class ShiftableBits a where
- shiftR :: a -> Word -> a
- shiftL :: a -> Word -> a
- uncheckedShiftR :: a -> Word -> a
- uncheckedShiftL :: a -> Word -> a
- shift :: a -> Int -> a
- uncheckedShift :: a -> Int -> a
- class SignedShiftableBits a where
- signedShiftR :: a -> Word -> a
- signedShiftL :: a -> Word -> a
- uncheckedSignedShiftR :: a -> Word -> a
- uncheckedSignedShiftL :: a -> Word -> a
- signedShift :: a -> Int -> a
- uncheckedSignedShift :: a -> Int -> a
Documentation
class ShiftableBits a where Source #
Bit shifts
Checked means that there is an additional test to ensure that the shift offset is valid (less than the bit count). If you are sure that the offset is valid, use the "unchecked" version which should be faster.
To shift signed numbers, see SignedShiftableBits
class methods.
shiftR :: a -> Word -> a Source #
Checked right shift
shiftL :: a -> Word -> a Source #
Checked left shift
uncheckedShiftR :: a -> Word -> a Source #
Unchecked right shift
uncheckedShiftL :: a -> Word -> a Source #
Unchecked left shift
shift :: a -> Int -> a Source #
Checked shift to the left if positive, to the right if negative
uncheckedShift :: a -> Int -> a Source #
Unchecked shift to the left if positive, to the right if negative
Instances
class SignedShiftableBits a where Source #
Signed bit shifts
Signed means that the sign bit (the higher order bit): - propagates to the right during right shifts and - keeps its value during left shifts (except when all other bits are 0)
Checked means that there is an additional test to ensure that the shift offset is valid (less than the bit count). If you are sure that the offset is valid, use the "unchecked" version which should be faster.
signedShiftR :: a -> Word -> a Source #
Checked signed right shift
signedShiftL :: a -> Word -> a Source #
Checked signed left shift
uncheckedSignedShiftR :: a -> Word -> a Source #
Unchecked signed right shift
uncheckedSignedShiftL :: a -> Word -> a Source #
Unchecked signed left shift
signedShift :: a -> Int -> a Source #
Checked signed shift to the left if positive, to the right if negative
uncheckedSignedShift :: a -> Int -> a Source #
Unchecked signed shift to the left if positive, to the right if negative