Bit Manipulation: AND, OR, XOR operations.

AND Operation:

AND operations on bit is represented by '&'. These are the rules for an '&' operation on bits:
  • 0&0=0
  • 1&0=0
  • 0&1=0
  • 1&1=0
When applying AND operation on binary with multiple bits, the only thing you have to do is to apply AND bit-wise. Apply AND to each corresponding pair of bits. Here are examples:
  • 1010 & 0101=0000
  • 1111 & 0000=0000
  • 1110 & 1010 = 1010

OR operation:

Or operation on bits is represented by '|'. These are the rules for a '|' operation on bits:
  • $0|0=0$
  • $1|0=1$
  • $0|1=1$
  • $1|1=1$
When applying OR operation on binary with multiple bits, the only thing you have to do is to apply OR bit-wise. Apply OR to each corresponding pair of bits.
  • $1010 | 0101=1111$
  • $1111 | 0000=1111$
  • $1110 | 1010 = 1110$

XOR operation:

Or operation on bits is represented by '^'. These are the rules for a '^' operation on bits:
  • $0^0=0$
  • $1^0=1$
  • $0^1=1$
  • $1^1=0$
When applying OR operation on binary with multiple bits, the only thing you have to do is to apply OR bit-wise. Apply OR to each corresponding pair of bits.
  • $1010 | 0101=1111$
  • $1111 | 0000=1111$
  • $1110 | 1010 = 0100$

No comments:

Post a Comment

Installing albert on ubuntu 19.04

Installing Albert on Ubuntu 19.04... Albert is not still released for ubuntu 19.04. But still, you can install it using the following ...