-- | Internal utilites
module Data.Word.Util where

import Data.Bits
import Data.Word

w16to32 :: Word16 -> Word16 -> Word32
w16to32 :: Word16 -> Word16 -> Word32
w16to32 Word16
w0s Word16
w1s =
    (Word32
w0 Word32 -> Int -> Word32
forall a. Bits a => a -> Int -> a
`shiftL` Int
16) Word32 -> Word32 -> Word32
forall a. Bits a => a -> a -> a
.|. Word32
w1
  where
    w0 :: Word32
w0 = Word16 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
w0s
    w1 :: Word32
w1 = Word16 -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
w1s

w32to64 :: Word32 -> Word32 -> Word64
w32to64 :: Word32 -> Word32 -> Word64
w32to64 Word32
w0s Word32
w1s =
    (Word64
w0 Word64 -> Int -> Word64
forall a. Bits a => a -> Int -> a
`shiftL` Int
32) Word64 -> Word64 -> Word64
forall a. Bits a => a -> a -> a
.|. Word64
w1
  where
    w0 :: Word64
w0 = Word32 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
w0s
    w1 :: Word64
w1 = Word32 -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
w1s