module Foundation.Bits
( (.<<.)
, (.>>.)
, Bits(..)
, alignRoundUp
, alignRoundDown
) where
import Basement.Compat.Base
import Foundation.Numerical
import Data.Bits hiding ((.<<.), (.>>.))
(.<<.) :: Bits a => a -> Int -> a
.<<. :: forall a. Bits a => a -> Int -> a
(.<<.) = a -> Int -> a
forall a. Bits a => a -> Int -> a
unsafeShiftL
(.>>.) :: Bits a => a -> Int -> a
.>>. :: forall a. Bits a => a -> Int -> a
(.>>.) = a -> Int -> a
forall a. Bits a => a -> Int -> a
unsafeShiftR
alignRoundUp :: Int
-> Int
-> Int
alignRoundUp :: Int -> Int -> Int
alignRoundUp Int
m Int
alignment = (Int
m Int -> Int -> Int
forall a. Additive a => a -> a -> a
+ (Int
alignmentInt -> Int -> Difference Int
forall a. Subtractive a => a -> a -> Difference a
-Int
1)) Int -> Int -> Int
forall a. Bits a => a -> a -> a
.&. Int -> Int
forall a. Bits a => a -> a
complement (Int
alignmentInt -> Int -> Difference Int
forall a. Subtractive a => a -> a -> Difference a
-Int
1)
alignRoundDown :: Int
-> Int
-> Int
alignRoundDown :: Int -> Int -> Int
alignRoundDown Int
m Int
alignment = Int
m Int -> Int -> Int
forall a. Bits a => a -> a -> a
.&. Int -> Int
forall a. Bits a => a -> a
complement (Int
alignmentInt -> Int -> Difference Int
forall a. Subtractive a => a -> a -> Difference a
-Int
1)