Logic Gate Calculator
Evaluate digital logic gates (AND, OR, NOT, NAND, NOR, XOR, XNOR) with instant results, interactive truth tables, and real-time output visualization.
Logic Gate Calculator
Evaluate digital logic gates (AND, OR, NOT, NAND, NOR, XOR, XNOR) with instant results and interactive truth tables.
Actions
Select Logic Gate
Input Values
Logic Gate Reference
Related tools
What are Logic Gates?
Logic gates are the fundamental building blocks of digital circuits and computer systems. They perform basic logical operations on one or more binary inputs (0 or 1) to produce a single binary output. Logic gates implement Boolean algebra and are used in processors, memory, controllers, and all digital devices. Understanding logic gates is essential for digital electronics, computer architecture, programming, and electrical engineering. The seven basic logic gates are AND, OR, NOT, NAND, NOR, XOR, and XNOR.
Basic Logic Gates
AND Gate (∧)
Operation: Output is 1 (HIGH) only when ALL inputs are 1. Otherwise, output is 0 (LOW).
Formula: Y = A · B or Y = A AND B
Example: 1 AND 1 = 1, 1 AND 0 = 0, 0 AND 0 = 0. Used in conditional logic, enable signals, and masking operations. Real-world: Door lock that requires both key AND code.
OR Gate (∨)
Operation: Output is 1 when AT LEAST ONE input is 1. Output is 0 only when all inputs are 0.
Formula: Y = A + B or Y = A OR B
Example: 1 OR 1 = 1, 1 OR 0 = 1, 0 OR 0 = 0. Used in combining signals, interrupt handling, and selection logic. Real-world: Alarm triggered by motion sensor OR door sensor.
NOT Gate (¬)
Operation: Output is the INVERSE of input. Also called inverter. Single input gate.
Formula: Y = Ā or Y = NOT A
Example: NOT 1 = 0, NOT 0 = 1. Used in signal inversion, complementing data, and creating other gates. Real-world: Light switch (ON becomes OFF, OFF becomes ON).
NAND Gate (⊼)
Operation: Output is 0 only when ALL inputs are 1. Inverse of AND gate. Universal gate.
Formula: Y = (A · B)' or Y = NOT (A AND B)
Example: 1 NAND 1 = 0, 1 NAND 0 = 1, 0 NAND 0 = 1. Universal gate - can create any other gate. Used extensively in IC design due to simplicity and versatility.
NOR Gate (⊽)
Operation: Output is 1 only when ALL inputs are 0. Inverse of OR gate. Universal gate.
Formula: Y = (A + B)' or Y = NOT (A OR B)
Example: 0 NOR 0 = 1, 1 NOR 0 = 0, 1 NOR 1 = 0. Universal gate - can create any other gate. Used in memory cells (SR latch) and control logic.
XOR Gate (⊕)
Operation: Output is 1 when inputs are DIFFERENT. Output is 0 when inputs are SAME. Exclusive OR.
Formula: Y = A ⊕ B or Y = A'B + AB'
Example: 1 XOR 0 = 1, 0 XOR 1 = 1, 1 XOR 1 = 0, 0 XOR 0 = 0. Used in adders, parity checkers, encryption, and error detection. Real-world: Comparing two values for difference.
XNOR Gate (⊙)
Operation: Output is 1 when inputs are SAME. Output is 0 when inputs are DIFFERENT. Inverse of XOR.
Formula: Y = (A ⊕ B)' or Y = AB + A'B'
Example: 1 XNOR 1 = 1, 0 XNOR 0 = 1, 1 XNOR 0 = 0. Also called equivalence gate. Used in comparators, error detection, and equality checking. Real-world: Password match verification.
Truth Tables Explained
A truth table shows all possible input combinations and their corresponding outputs for a logic gate. It's a complete specification of gate behavior. For n inputs, there are 2n possible combinations.
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
Reading Truth Tables: Each row represents one possible input combination. The output column shows the gate's response. Truth tables are used for circuit design, verification, and debugging.
Universal Gates
Logic Gate Applications
Boolean Algebra and Logic Gates
Basic Boolean Laws
Identity Law: A + 0 = A, A · 1 = A
Null Law: A + 1 = 1, A · 0 = 0
Idempotent Law: A + A = A, A · A = A
Complement Law: A + A' = 1, A · A' = 0
Commutative Law: A + B = B + A, A · B = B · A
Associative Law: (A + B) + C = A + (B + C)
Distributive Law: A · (B + C) = A · B + A · C
De Morgan's Theorem: (A + B)' = A' · B', (A · B)' = A' + B'
Boolean algebra provides mathematical foundation for logic gates. These laws allow circuit simplification, optimization, and transformation. De Morgan's theorem is particularly useful for converting between NAND/NOR and other gates. Understanding Boolean algebra is essential for digital design and computer science.
Logic Gate Implementation
Frequently Asked Questions
What is the difference between AND and NAND?
AND outputs 1 only when all inputs are 1. NAND is its inverse: it outputs 0 only when all inputs are 1, and 1 otherwise.
What is an XOR gate used for?
XOR outputs 1 when its two inputs differ. It gives the sum bit in a half adder, checks parity, compares bits and flips a bit when XORed with 1.
Why are NAND and NOR universal gates?
Any other gate can be built from NAND gates alone, or from NOR gates alone. For example, a NAND with its inputs tied together is a NOT gate.
How do I read a truth table?
Each row is one combination of inputs and the output it produces. n inputs give 2ⁿ rows: 4 for two inputs, 8 for three.
What voltages represent 0 and 1?
It depends on the logic family. 5 V TTL reads below 0.8 V as 0 and above 2 V as 1. 3.3 V CMOS reads below about 0.8 V as 0 and above about 2 V as 1. Use a level shifter between families.
💡 Pro Tip
When learning logic gates, start with truth tables - they provide complete understanding of gate behavior. Practice converting between different gate types using Boolean algebra and De Morgan's theorem. Remember that NAND and NOR are universal gates - understanding how to build other gates from them is crucial for digital design. Use online simulators to visualize complex circuits before building hardware. When debugging digital circuits, check truth tables systematically for each gate. For exam preparation, memorize truth tables for all seven basic gates and practice Boolean simplification. In practical applications, always consider propagation delay and power consumption when selecting gate types.
How to Use the Logic Gate Calculator
- 1Choose the gate: Select AND, OR, NOT, NAND, NOR, XOR or XNOR.
- 2Set the inputs: Toggle each input between 0 and 1. AND, OR, NAND and NOR accept more than two inputs; NOT takes one.
- 3Read the output: See the output and a one-line explanation of why.
- 4Check the truth table: Review every input combination and its output, and export the table as CSV or text.
Related Tools
PWM Duty Cycle Calculator
Calculate PWM duty cycle.
ADC Resolution Calculator
Determine ADC resolution.
DAC Output Calculator
Compute analog output from digital input.
Clock Frequency Calculator
Calculate clock frequency.
Data Rate Calculator
Compute data transmission rate.
Antenna Length Calculator
Determine antenna length for frequency.
RF Power Calculator
Calculate RF signal power.
Lightning Protection Calculator
Estimate protection requirements.
Power Loss Calculator
Calculate losses in electrical systems.
UPS Load Calculator
Calculate required UPS capacity for your devices.
UPS Backup Calculator
Calculate how long your UPS will run.
Current Divider Calculator
Calculate current distribution.