summaryrefslogtreecommitdiff
path: root/libraries/base/Data/Bits.hs
diff options
context:
space:
mode:
authorMalcolm.Wallace@cs.york.ac.uk <unknown>2009-10-09 13:32:57 +0000
committerMalcolm.Wallace@cs.york.ac.uk <unknown>2009-10-09 13:32:57 +0000
commit395111227ced817b9db2b0a109b247b1cf657a3d (patch)
tree587ffb20714a59ac66446fddb656be4704240952 /libraries/base/Data/Bits.hs
parentef624c412dd2650ed665a4037673ed7b9184aa8e (diff)
downloadhaskell-395111227ced817b9db2b0a109b247b1cf657a3d.tar.gz
Fix gratuitous breakage for non-GHC in Data.Bits.
Diffstat (limited to 'libraries/base/Data/Bits.hs')
-rw-r--r--libraries/base/Data/Bits.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs
index 9b313970db..890909c03e 100644
--- a/libraries/base/Data/Bits.hs
+++ b/libraries/base/Data/Bits.hs
@@ -273,6 +273,8 @@ instance Bits Integer where
(.|.) = orInteger
xor = xorInteger
complement = complementInteger
+ shift x i@(I# i#) | i >= 0 = shiftLInteger x i#
+ | otherwise = shiftRInteger x (negateInt# i#)
#else
-- reduce bitwise binary operations to special cases we can handle
@@ -289,11 +291,10 @@ instance Bits Integer where
-- assuming infinite 2's-complement arithmetic
complement a = -1 - a
+ shift x i | i >= 0 = x * 2^i
+ | otherwise = x `div` 2^(-i)
#endif
- shift x i@(I# i#) | i >= 0 = shiftLInteger x i#
- | otherwise = shiftRInteger x (negateInt# i#)
-
rotate x i = shift x i -- since an Integer never wraps around
bitSize _ = error "Data.Bits.bitSize(Integer)"