
#7860: Add more bit fiddling functions to 'integer-gmp' --------------------------------+------------------------------------------- Reporter: lebedev | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: libraries (other) | Version: 7.6.3 Resolution: | Keywords: gmp Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: #3489 --------------------------------+------------------------------------------- Comment(by lebedev): Actually, there should also be a case for negative bits, so the full version is: {{{ clearBitInteger :: Integer -> Int# -> Integer clearBitInteger (S# j) i | i <# 0# || i >=# (WORD_SIZE_IN_BITS# -# 1#) = S# j | otherwise = let !mask = int2Word# (1# `uncheckedIShiftL#` i) `xor#` int2Word# (negateInt# 1#) in S# (word2Int# (int2Word# j `and#` mask)) clearBitInteger (J# s d) i = let !(# s', d' #) = clearBitInteger# s d i in J# s' d' }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7860#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler