word24 0.1.0 → 0.1.2
raw patch · 3 files changed
+14/−15 lines, 3 filesdep ~base
Dependency ranges changed: base
Files
- src/Data/Int/Int24.hs +8/−7
- src/Data/Word/Word24.hs +4/−6
- word24.cabal +2/−2
src/Data/Int/Int24.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE MagicHash, NoImplicitPrelude #-}-{-# OPTIONS_HADDOCK hide #-}+ ----------------------------------------------------------------------------- -- | -- Module : Data.Int.Int24@@ -9,7 +9,7 @@ -- Stability : experimental -- Portability : non-portable (GHC Extensions) ----- The 3 bit integral datatypes, 'Int24'.+-- The 24 bit integral datatype, 'Int24'. -- ----------------------------------------------------------------------------- @@ -34,6 +34,7 @@ import GHC.Int import GHC.Show import GHC.Ptr+import GHC.Err ------------------------------------------------------------------------ -- type Int24@@ -53,8 +54,8 @@ then word2Int# ( x'# `or#` int2Word# 0xFF800000# ) else word2Int# ( x'# `and#` (int2Word# 0xFFFFFF#)) where- x'# = int2Word# x#- mask# = int2Word# 0x00800000#+ !x'# = int2Word# x#+ !mask# = int2Word# 0x00800000# instance Show Int24 where showsPrec p x = showsPrec p (fromIntegral x :: Int)@@ -146,9 +147,9 @@ = I24# (narrow24Int# (word2Int# ((x'# `uncheckedShiftL#` i'#) `or#` (x'# `uncheckedShiftRL#` (24# -# i'#))))) where- x'# = narrow24Word# (int2Word# x#)- I# i0# = i `mod` 24- i'# = word2Int# (narrow24Word# (int2Word# i0#))+ !x'# = narrow24Word# (int2Word# x#)+ !(I# i0#) = i `mod` 24+ !i'# = word2Int# (narrow24Word# (int2Word# i0#)) bitSize _ = 24 isSigned _ = True
src/Data/Word/Word24.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE MagicHash #-}-{-# OPTIONS_HADDOCK hide #-} -- | -- Module : Data.Word.Word24@@ -7,7 +6,7 @@ -- Stability : experimental -- Portability : non-portable (GHC Extensions) --- Provide a three-byte unsigned integral type: 'Word24', analagous to Word8,+-- Provide a 24-bit unsigned integral type: 'Word24', analagous to Word8, -- Word16, etc. -- @@ -26,11 +25,10 @@ import GHC.Enum import GHC.Num import GHC.Real-import GHC.Read import GHC.Arr-import GHC.Show import GHC.Word import GHC.Ptr+import GHC.Err -- Word24 is represented in the same way as Word. Operations may assume and -- must ensure that it holds only values in its logical range.@@ -114,7 +112,7 @@ (W24# x#) .&. (W24# y#) = W24# (x# `and#` y#) (W24# x#) .|. (W24# y#) = W24# (x# `or#` y#) (W24# x#) `xor` (W24# y#) = W24# (x# `xor#` y#)- complement (W24# x#) = W24# (x# `xor#` mb#) where W24# mb# = maxBound+ complement (W24# x#) = W24# (x# `xor#` mb#) where !(W24# mb#) = maxBound (W24# x#) `shift` (I# i#) | i# >=# 0# = W24# (narrow24Word# (x# `shiftL#` i#)) | otherwise = W24# (x# `shiftRL#` negateInt# i#)@@ -123,7 +121,7 @@ | otherwise = W24# (narrow24Word# ((x# `uncheckedShiftL#` i'#) `or#` (x# `uncheckedShiftRL#` (24# -# i'#)))) where- I# i'# = i `mod` 24+ !(I# i'#) = i `mod` 24 bitSize _ = 24 isSigned _ = False
word24.cabal view
@@ -1,5 +1,5 @@ name: word24-version: 0.1.0+version: 0.1.2 synopsis: 24-bit word and int types for GHC description: 24-bit Word and Int data types. category: Data@@ -8,7 +8,7 @@ license: BSD3 license-file: LICENSE homepage: http://inmachina.net/~jwlato/haskell/word24-tested-with: GHC == 6.10.4, GHC == 6.10.3+tested-with: GHC == 6.12.1, GHC == 6.10.4 stability: experimental cabal-version: >= 1.6