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
  • 16
    Why would you expect it to be 9? Commented 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. Commented Apr 24, 2018 at 9:46

1 Answer 1

38

Because 6 AND 9 = 0

0110   = 6
&
1001   = 9
-----
0000   = 0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.