@@ -0,0 +1,36 @@
1+
2+-- | Internal utilites
3+module Data.Word.Util where
4+
5+import Data.Bits
6+import Data.Word
7+
8+w8to32 :: Word8 -> Word8 -> Word8 -> Word8 -> Word32
9+w8to32 w0s w1s w2s w3s =
10+ (w0 `shiftL` 24) .|. (w1 `shiftL` 16) .|. (w2 `shiftL` 8) .|. w3
11+ where
12+ w0 = fromIntegral w0s
13+ w1 = fromIntegral w1s
14+ w2 = fromIntegral w2s
15+ w3 = fromIntegral w3s
16+
17+w8to16 :: Word8 -> Word8 -> Word16
18+w8to16 w0s w1s =
19+ (w0 `shiftL` 8) .|. w1
20+ where
21+ w0 = fromIntegral w0s
22+ w1 = fromIntegral w1s
23+
24+w16to32 :: Word16 -> Word16 -> Word32
25+w16to32 w0s w1s =
26+ (w0 `shiftL` 16) .|. w1
27+ where
28+ w0 = fromIntegral w0s
29+ w1 = fromIntegral w1s
30+
31+w32to64 :: Word32 -> Word32 -> Word64
32+w32to64 w0s w1s =
33+ (w0 `shiftL` 32) .|. w1
34+ where
35+ w0 = fromIntegral w0s
36+ w1 = fromIntegral w1s