The Bitwise Logical Operators

The bitwise logical operators are &, |, ^, and ~.

The following table shows the outcome of each operation.

Bitwise logical operators ant its result

ABA | B A & B A ^ B~A
000001
101010
011011
111100

The Bitwise NOT (bitwise complement)

The unary NOT operator, ~, inverts all of the bits of its operand. For example, the number 42, which has the following bit pattern:


00101010

becomes


11010101

after the NOT operator is applied.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.