Use shift[LR]Integer in the Bits Integer instance
authorIan Lynagh <igloo@earth.li>
Tue, 21 Jul 2009 22:24:40 +0000 (22:24 +0000)
committerIan Lynagh <igloo@earth.li>
Tue, 21 Jul 2009 22:24:40 +0000 (22:24 +0000)
Data/Bits.hs

index 46f009a..9b31397 100644 (file)
@@ -48,7 +48,6 @@ module Data.Bits (
 
 #ifdef __GLASGOW_HASKELL__
 import GHC.Num
-import GHC.Real
 import GHC.Base
 #endif
 
@@ -292,8 +291,8 @@ instance Bits Integer where
    complement a = -1 - a
 #endif
 
-   shift x i | i >= 0    = x * 2^i
-             | otherwise = x `div` 2^(-i)
+   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