Greg Peckory
Greg Peckory

Reputation: 8058

Using bitwise AND operation in haskell

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 !

Upvotes: 1

Views: 8760

Answers (1)

Eugene Sh.
Eugene Sh.

Reputation: 18321

Because 6 AND 9 = 0

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

Upvotes: 36

Related Questions