1

why doesn't the code

import Data.Bits

a = (.&.) 6 9

give me

9

Can someone explain to me why this doesn't work. Cheers !

2
  • 15
    Why would you expect it to be 9?
    – molbdnilo
    Dec 16, 2014 at 15:00
  • 6
    On a side note, I came here to check that .&. is indeed how Haskell defines the bitwise and operator. Apr 24, 2018 at 9:46

1 Answer 1

35

Because 6 AND 9 = 0

0110   = 6
&
1001   = 9
-----
0000   = 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.