* 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
fromInteger = to . fromInteger
fromInt = to
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
instance Real Int32 where
toRational x = toInteger x % 1
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)
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#)
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#))
setBit x i = x .|. bit i
clearBit x i = x .&. complement (bit i)
complementBit x i = x `xor` bit i
setBit x i = x .|. bit i
clearBit x i = x .&. complement (bit i)
complementBit x i = x `xor` bit i