diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-08-05 15:56:00 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-08-05 15:56:00 +0100 |
commit | fb83206fcfaf0b7799e5144579be1dd42fbdf405 (patch) | |
tree | a158099c2613e74bc62b2026869fdee3af0a534b /libraries/integer-simple | |
parent | 9f0eca5a93e5b07811274629f2844a60515cbcbd (diff) | |
download | haskell-fb83206fcfaf0b7799e5144579be1dd42fbdf405.tar.gz |
Define testBitInteger; part of #3489. Patch from pumpkingod@gmail.com
Diffstat (limited to 'libraries/integer-simple')
-rw-r--r-- | libraries/integer-simple/GHC/Integer.hs | 2 | ||||
-rw-r--r-- | libraries/integer-simple/GHC/Integer/Type.hs | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/libraries/integer-simple/GHC/Integer.hs b/libraries/integer-simple/GHC/Integer.hs index 4122d382fd..3bc8f16ebc 100644 --- a/libraries/integer-simple/GHC/Integer.hs +++ b/libraries/integer-simple/GHC/Integer.hs @@ -33,7 +33,7 @@ module GHC.Integer ( encodeDoubleInteger, decodeDoubleInteger, doubleFromInteger, -- gcdInteger, lcmInteger, -- XXX andInteger, orInteger, xorInteger, complementInteger, - shiftLInteger, shiftRInteger, + shiftLInteger, shiftRInteger, testInteger, hashInteger, ) where diff --git a/libraries/integer-simple/GHC/Integer/Type.hs b/libraries/integer-simple/GHC/Integer/Type.hs index 67ed19c6bb..ee2c08f6f0 100644 --- a/libraries/integer-simple/GHC/Integer/Type.hs +++ b/libraries/integer-simple/GHC/Integer/Type.hs @@ -314,6 +314,13 @@ shiftRInteger j@(Negative _) i = complementInteger (shiftRInteger (complementInteger j) i) shiftRInteger Naught _ = Naught +-- XXX this could be a lot more efficient, but this is a quick +-- reimplementation of the default Data.Bits instance, so that we can +-- implement the Integer interface +testBitInteger :: Integer -> Int# -> Bool +testBitInteger x i = (x `andInteger` (smallInteger 1# `shiftLInteger` i)) + `neqInteger` smallInteger 0# + twosComplementPositive :: Positive -> DigitsOnes twosComplementPositive p = flipBits (p `minusPositive` onePositive) |