From: simonm Date: Thu, 20 Nov 1997 16:45:38 +0000 (+0000) Subject: [project @ 1997-11-20 16:45:38 by simonm] X-Git-Tag: Approx_2487_patches~1289 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=38d3857b4567eba1ac1082df1d4f764187da7feb;p=ghc-hetmet.git [project @ 1997-11-20 16:45:38 by simonm] * fix minBound::Int32 in view of the fact that minBound::Int is wrong. * fix shift direction (it was reversed) * fix complement to be a 1's complement instead of 2's complement --- diff --git a/ghc/lib/glaExts/Int.lhs b/ghc/lib/glaExts/Int.lhs index b539bae..1ef116f 100644 --- a/ghc/lib/glaExts/Int.lhs +++ b/ghc/lib/glaExts/Int.lhs @@ -244,9 +244,11 @@ instance Num Int32 where fromInteger = to . fromInteger fromInt = to -instance Bounded Int32 where - minBound = to minBound - maxBound = to maxBound +-- ToDo: remove LitLit when minBound::Int is fixed (currently it's one +-- too high, and doesn't allow the correct minBound to be defined here). +instance Bounded Int32 where + minBound = I32 ``0x80000000'' + maxBound = I32 0x7fffffff instance Real Int32 where toRational x = toInteger x % 1 @@ -284,12 +286,12 @@ instance Bits Int32 where x .&. y = to (binop (wordop and#) x y) x .|. y = to (binop (wordop or# ) x y) x `xor` y = to (binop (wordop xor#) x y) - complement x = (x `xor` maxBound) + 1 + complement x = x `xor` -1 shift (I32 (I# x)) i@(I# i#) - | i > 0 = I32 (I# (iShiftRL# x i#)) - | otherwise = I32 (I# (iShiftL# x i#)) + | i > 0 = I32 (I# (iShiftL# x i#)) + | otherwise = I32 (I# (iShiftRA# x i#)) -- rotate - bit i = 1 `shift` -i + bit i = 1 `shift` i setBit x i = x .|. bit i clearBit x i = x .&. complement (bit i) complementBit x i = x `xor` bit i