foundation-0.0.3: Alternative prelude with batteries and no dependencies

Safe Haskell | None
Language | Haskell2010

Foundation.Bits

Synopsis

- (.<<.) :: Bits a => a -> Int -> a
- (.>>.) :: Bits a => a -> Int -> a
- alignRoundUp :: Int -> Int -> Int
- alignRoundDown :: Int -> Int -> Int

# Documentation

(.<<.) :: Bits a => a -> Int -> a #

Unsafe Shift Left Operator

(.>>.) :: Bits a => a -> Int -> a #

Unsafe Shift Right Operator

alignRoundUp #

Arguments

:: Int | Number to Align
-> Int | Alignment (power of 2)
-> Int |

Round up (if needed) to a multiple of `alignment` closst to `m`

`alignment` needs to be a power of two

alignRoundUp 16 8 = 16 alignRoundUp 15 8 = 16

alignRoundDown #

Arguments

:: Int | Number to Align
-> Int | Alignment (power of 2)
-> Int |

Round down (if needed) to a multiple of `alignment` closest to `m`

`alignment` needs to be a power of two

    alignRoundDown 15 8 = 8
    alignRoundDown 8 8  = 8