Logic cơ bản
NOT
- Ký hiệu
- ¬A, A'
- Lập trình
- Mạch
- Inverter gate
Ví dụ
Reverses a truth value.
If A means logged in, ¬A means not logged in.
Bảng chân trị
| A | Out |
|---|---|
| 0 | 1 |
| 1 | 0 |
Tài liệu khoa học máy tính
Tìm hiểu AND, OR, NOT, XOR, NAND, NOR và các toán tử liên quan qua bảng chân trị, đại số Boolean, mạch số, lập trình và ví dụ câu hỏi AI.
Logic cơ bản
Reverses a truth value.
If A means logged in, ¬A means not logged in.
| A | Out |
|---|---|
| 0 | 1 |
| 1 | 0 |
Logic cơ bản
True only when every input is true.
isLoggedIn && hasPermission
| A | B | Out |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Logic cơ bản
True when at least one input is true.
isAdmin || isOwner
| A | B | Out |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Toán tử dẫn xuất
True when the inputs are different.
Half adder sum = A XOR B.
| A | B | Out |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Toán tử dẫn xuất
The negation of AND. NAND gates can build any Boolean circuit.
A NAND B = NOT (A AND B).
| A | B | Out |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Toán tử dẫn xuất
The negation of OR. NOR is also functionally complete.
A NOR B is true only when both inputs are false.
| A | B | Out |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Toán tử dẫn xuất
True when the inputs are the same.
A XNOR B behaves like equality for Boolean values.
| A | B | Out |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Toán tử bit
Applies AND to each bit position. It is different from logical &&.
0101 & 0011 = 0001
Lập trình
The second expression may not run if the first expression already determines the result.
user && user.name
A ∧ 1 = A, A ∨ 0 = ACombining with the neutral truth value leaves A unchanged.
A ∧ 0 = 0, A ∨ 1 = 1One fixed input can determine the entire result.
A ∧ ¬A = 0, A ∨ ¬A = 1A statement and its negation cannot both be true, but at least one is true.
¬(A ∧ B) = ¬A ∨ ¬B, ¬(A ∨ B) = ¬A ∧ ¬BMoves a negation across AND or OR while switching the operator.
A ∨ (A ∧ B) = A, A ∧ (A ∨ B) = AA repeated condition can absorb a more specific condition.