基本邏輯
NOT
- 標記
- ¬A, A'
- 程式設計
- 電路
- Inverter gate
範例
Reverses a truth value.
If A means logged in, ¬A means not logged in.
真值表
| A | Out |
|---|---|
| 0 | 1 |
| 1 | 0 |
電腦科學學習資料
整理 AND、OR、NOT、XOR、NAND、NOR 等邏輯運算,並搭配真值表、布林代數、數位電路、程式設計與 AI 提問範例。
基本邏輯
Reverses a truth value.
If A means logged in, ¬A means not logged in.
| A | Out |
|---|---|
| 0 | 1 |
| 1 | 0 |
基本邏輯
True only when every input is true.
isLoggedIn && hasPermission
| A | B | Out |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
基本邏輯
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 |
衍生運算
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 |
衍生運算
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 |
衍生運算
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 |
衍生運算
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 |
位元運算
Applies AND to each bit position. It is different from logical &&.
0101 & 0011 = 0001
程式設計
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.