Wednesday, March 9, 2011

2.9 Bitwise Operators

  • Six operators for bit manipulation:












  • The operators can only be applied to integral operands - int, char, short and long (signed or unsigned)
  • bitwise AND operator is often used to mask off some set of bits
  • bitwise inclusive OR operator is used to turn bits on
  • bitwise exclusive OR operator set a one in each bit position where its operands have different bits, and zero where they are the same
  • Shift operator shift the bit position of operand and fill vacated bits with zero
  • Unary operator yields the one's complement of an integer (convert each 1-bit into 0-bit and vice versa)

No comments:

Post a Comment