Logical operations are performed between two data bits (except for NOT). Bits
can be either "1" or "0", and these operations are essential to performing
digital math operations.
In the "truth tables" below, the input bits are in bold, and the results
are plain.
The logical AND operation compares 2 bits and if they are both "1", then the result is "1", otherwise, the result is "0".
0 | 1 | |
0 | 0 | 0 |
1 | 0 | 1 |
The logical OR operation compares 2 bits and if either or both bits are "1", then the result is "1", otherwise, the result is "0".
0 | 1 | |
0 | 0 | 1 |
1 | 1 | 1 |
The logical XOR (Exclusive OR) operation compares 2 bits and if exactly one of them is "1" (i.e., if they are different values), then the result is "1"; otherwise (if the bits are the same), the result is "0".
0 | 1 | |
0 | 0 | 1 |
1 | 1 | 0 |
The logical NOT operation simply changes the value of a single bit. If it is a "1", the result is "0"; if it is a "0", the result is "1". Note that this operation is different in that instead of comparing two bits, it is acting on a single bit.
0 | 1 |
1 | 0 |