Csharp/CSharp Tutorial/Operator/Bitwise Operator

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Bitwise Compound Assignments

All of the binary bitwise operators can be used in compound assignments.


x = x ^ 127;
  x ^= 127;

The Bitwise Operators

  1. The bitwise operators act directly upon the bits of their operands.
  2. They are defined only for integer operands.
  3. They cannot be used on bool, float, or double.

The Bitwise Operators

Operator Result & Bitwise AND | Bitwise OR ^ Bitwise exclusive OR (XOR) > Shift right < Shift left ~ One"s complement (unary NOT) p q p & q p | q p ^ q ~p 0 0 0 0 0 1 1 0 0 1 1 0 0 1 0 1 1 1 1 1 1 1 0 0