I just started learning about bit wise operation and want to ask why and 1 ( &1) bitwise operation always return 0 or 1 .
0 & 0 === 0
0 & 1 === 0
1 & 0 === 0
1 & 1 === 1
therefore any number & 1 will always be either 0 or 1
in binary ... any number
xxxxxxxxxxxxx0
or
xxxxxxxxxxxxx1
where x can be 0 or 1
1 in binary is
00000000000001
so
xxxxxxxxxxxxx1 &
00000000000001 ==
00000000000001
xxxxxxxxxxxxx0 &
00000000000001 ==
00000000000000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With