word24 1.0.6 → 1.0.7
raw patch · 3 files changed
+25/−7 lines, 3 filesdep ~base
Dependency ranges changed: base
Files
- src/Data/Int/Int24.hs +13/−4
- src/Data/Word/Word24.hs +11/−2
- word24.cabal +1/−1
src/Data/Int/Int24.hs view
@@ -56,7 +56,7 @@ -- if the 24th bit (from right) is on, the value is negative, so -- fill the uppermost bits with 1s. Otherwise clear them to 0s. narrow24Int# :: Int# -> Int#-narrow24Int# x# = if (x'# `and#` mask#) `eqWord#` mask#+narrow24Int# x# = if primBool ((x'# `and#` mask#) `eqWord#` mask#) then word2Int# ( x'# `or#` int2Word# m1# ) else word2Int# ( x'# `and#` (int2Word# m2#)) where@@ -147,10 +147,10 @@ (I24# x#) `xor` (I24# y#) = I24# (word2Int# (int2Word# x# `xor#` int2Word# y#)) complement (I24# x#) = I24# (word2Int# (int2Word# x# `xor#` int2Word# (-1#))) (I24# x#) `shift` (I# i#)- | i# >=# 0# = I24# (narrow24Int# (x# `iShiftL#` i#))- | otherwise = I24# (x# `iShiftRA#` negateInt# i#)+ | primBool (i# >=# 0# ) = I24# (narrow24Int# (x# `iShiftL#` i#))+ | otherwise = I24# (x# `iShiftRA#` negateInt# i#) (I24# x#) `rotate` i- | i'# ==# 0# = I24# x#+ | primBool (i'# ==# 0# ) = I24# x# | otherwise = I24# (narrow24Int# (word2Int# ((x'# `uncheckedShiftL#` i'#) `or#` (x'# `uncheckedShiftRL#` (24# -# i'#)))))@@ -184,3 +184,12 @@ alignment _ = 3 peek p = fmap fromIntegral $ peek ((castPtr p) :: Ptr Word24) poke p v = poke (castPtr p :: Ptr Word24) (fromIntegral v)++#if MIN_VERSION_base(4,7,0)+primBool :: Int# -> Bool+primBool x = tagToEnum# x+#else+primBool :: Bool -> Bool+primBool = id+#endif+
src/Data/Word/Word24.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash, BangPatterns #-} -- |@@ -114,10 +115,10 @@ (W24# x#) `xor` (W24# y#) = W24# (x# `xor#` y#) complement (W24# x#) = W24# (x# `xor#` mb#) where !(W24# mb#) = maxBound (W24# x#) `shift` (I# i#)- | i# >=# 0# = W24# (narrow24Word# (x# `shiftL#` i#))+ | primBool (i# >=# 0#) = W24# (narrow24Word# (x# `shiftL#` i#)) | otherwise = W24# (x# `shiftRL#` negateInt# i#) (W24# x#) `rotate` i- | i'# ==# 0# = W24# x#+ | primBool (i'# ==# 0#) = W24# x# | otherwise = W24# (narrow24Word# ((x# `uncheckedShiftL#` i'#) `or#` (x# `uncheckedShiftRL#` (24# -# i'#)))) where@@ -131,6 +132,14 @@ {-# INLINE shiftR #-} x `shiftR` i = x `shift` (-i)++#if MIN_VERSION_base(4,7,0)+primBool :: Int# -> Bool+primBool x = tagToEnum# x+#else+primBool :: Bool -> Bool+primBool = id+#endif {-# RULES "fromIntegral/Word8->Word24" fromIntegral = \(W8# x#) -> W24# x#
word24.cabal view
@@ -1,5 +1,5 @@ name: word24-version: 1.0.6+version: 1.0.7 synopsis: 24-bit word and int types for GHC description: 24-bit Word and Int data types. category: Data