Logical operations in computers (AND, OR, NOT, XOR, EXCLUSIVE OR, NAND, NOR)

Logical operations in computers are also called "Boolean operations", which are: AND , OR , NOT , and XOR . In addition, there are: same or , NAND , NOR in the gate circuit . There are seven types in total.

Among these seven logical operations, only the logical NOT operation is a unary logical operation (one operand), and the other six are binary logical operations (two operands).

Logical operations have only two Boolean values:

  • 0, indicating a false value (False).
  • 1, indicating the true value (True).

1. AND(AND)&

Logical expression: F=AB

Logical AND operation, operation rules: all 1s are 1, and 0s are 0 . That is, the result is 1 only when both operands are 1, and 0 in other cases (it can also be said that as long as there is 0, the result is 0).

Operand 1 Operand 2 result value
1 1 1
1 0 0
0 1 0
0 0 0

2. 或(OR)|

Logical expression: F=A+B.
(Also written as A∨B (logic), A || B (computer science), or A + B (electronics))

Logical OR operation, operation rules: all 0s are 0, and 1 is 1 . That is, the result is 0 only when both operands are 0, and 1 in other cases (it can also be said that as long as there is 1, the result is 1).

Operand 1 Operand 2 result value
1 1 1
1 0 1
0 1 1
0 0 0

3. NOT (NOT)~

Logical expression:
Insert image description here
Logical NOT operation has only one operand, so it is a unary logical operation.
Operation rules: 1 changes to 0, 0 changes to 1 . That is, when the operand is 1, the result is 0, and when the operand is 0, the result is 1.

operand result value
1 0
0 1

4. Exclusive OR (XOR)^

Logical expression:
Insert image description here
logical XOR operation, operation rules: difference is 1, sameness is 0 . That is, the result is 1 when the two operands are different, and the result is 0 when the two operands are the same.

Operand 1 Operand 2 result value
1 1 0
1 0 1
0 1 1
0 0 0

5. XNOR

Logical expression:
Insert image description here

Logical same-or operation, operation rules: the same is 1, the difference is 0 . Contrary to the rules of XOR operation. That is, the result is 1 when the two operands are the same, and the result is 0 when the two operands are different.

Operand 1 Operand 2 result value
1 1 1
1 0 0
0 1 0
0 0 1

6. NAND

Logical expression:
Insert image description here
logical AND and NOT operation, operation rules: AND first and then NOT (all 1s are 0s, and 0s are 1) . That is to say, first perform a "logical AND operation" on the two operands, and then perform a "logical NOT operation" on the AND "operation result value" to produce the final result.

Operand 1 Operand 2 AND operation result value final result value
1 1 1 0
1 0 0 1
0 1 0 1
0 0 0 1

7. NOR

Logical expression:
Insert image description here
logical OR operation, operation rules: OR first and then NOT (all 0s are 1, and 1 is 0) . That is, perform a "logical OR operation" on the two operands first, and then perform a "logical NOT operation" on the "OR operation result value" to produce the final result.

Operand 1 Operand 2 OR result value final result value
1 1 1 0
1 0 1 0
0 1 1 0
0 0 0 1

Guess you like

Origin blog.csdn.net/weixin_37909391/article/details/131441253