B
This commit is contained in:
parent
e5e8880e41
commit
518da4a923
1019 changed files with 15877 additions and 0 deletions
18
Task/Bitwise-operations/Haskell/bitwise-operations.hs
Normal file
18
Task/Bitwise-operations/Haskell/bitwise-operations.hs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import Data.Bits
|
||||
|
||||
bitwise :: Int -> Int -> IO ()
|
||||
bitwise a b = do
|
||||
print $ a .&. b
|
||||
print $ a .|. b
|
||||
print $ a `xor` b
|
||||
print $ complement a
|
||||
print $ shiftL a b -- left shift
|
||||
print $ shiftR a b -- arithmetic right shift
|
||||
print $ shift a b -- You can also use the "unified" shift function; positive is for left shift, negative is for right shift
|
||||
print $ shift a (-b)
|
||||
print $ rotateL a b -- rotate left
|
||||
print $ rotateR a b -- rotate right
|
||||
print $ rotate a b -- You can also use the "unified" rotate function; positive is for left rotate, negative is for right rotate
|
||||
print $ rotate a (-b)
|
||||
|
||||
main = bitwise 255 170
|
||||
Loading…
Add table
Add a link
Reference in a new issue