# Logic gates > How do AND, OR, NOT and XOR gates work? Switch the inputs and see each logic gate's output at once, with its symbol in both standard styles, its Boolean expression and truth table. AND, OR, NOT, NAND, NOR, XOR and XNOR gates: toggle the inputs, see the output, the ANSI and IEC symbols, the Boolean expression and the truth table. - Page: https://how.box/logic-gates/ - Runs entirely in the browser. - License: HowToolbox's own text and data (titles, explanations, FAQs, tool descriptions and schemas, this file) are CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/); AI training and answers are welcome. Attribute "HowToolbox (how.box)" with a link to the page used. Third-party data keeps its own terms; the name and logo are not licensed. Publisher: HowToolbox, contact@how.box. Terms: https://how.box/about/terms/ ## Inputs Answer link: https://how.box/logic-gates/?g={g}&n={n}&i={i}&s={s} - `g` (and, or, not, nand, nor, xor, xnor or buffer): The gate: and, or, not, nand, nor, xor, xnor or buffer. Example: `nand`. - `n` (whole number 2 to 8): Number of inputs, 2 to 8. Example: `3`. - `i` (text): Input values A to H, eight digits 0 or 1. Example: `11100000`. - `s` (distinctive or rectangular): Symbol style: distinctive or rectangular. Example: `rectangular`. Example answer: https://how.box/logic-gates/?g=nand&n=3&i=11100000&s=rectangular A complete link carries the primary answer in the page HTML; a missing or invalid value shows the default page. ## Agent tools - `logic_gates_evaluate`: Evaluates a logic gate (AND, OR, NOT, NAND, NOR, XOR, XNOR, BUFFER) for given inputs. - MCP: POST https://how.box/mcp `tools/call` with `{"name":"logic_gates_evaluate","arguments":{…}}`; input schema in https://how.box/agent-tools.json. - `logic_gates_truth_table`: Gives the truth table output column and the Boolean expression of a logic gate with 2 to 8 inputs. - MCP, one POST to https://how.box/mcp: `{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"logic_gates_truth_table","arguments":{"gate":"nand","count":3}}}` - GET: https://how.box/mcp/run/logic_gates_truth_table?gate=nand&count=3 ## How it works A logic gate is the smallest building block of digital electronics. It takes one or two inputs that are either 1 (on, high voltage) or 0 (off, low voltage) and gives one output. Its rule is a Boolean function, and its truth table lists the output for every combination of inputs. Two inputs have four combinations: 00, 01, 10 and 11. AND is written A · B and gives 1 only for 11. OR is A + B and gives 1 unless both inputs are 0. NOT, written ¬A, flips its single input. XOR, A ⊕ B, gives 1 when the inputs differ. NAND, NOR and XNOR are AND, OR and XOR followed by NOT: the small circle on a symbol means the output is inverted. Example: 1 XOR 1 gives 0, and 1 NAND 1 gives 0, while 1 NAND 0 gives 1. Two symbol styles are in use. The distinctive shapes, D-shaped AND and shield-shaped OR, come from IEEE Std 91 (ANSI) and are common in American and older drawings. The international standard IEC 60617-12 draws every gate as a box and writes its function inside: & for AND, ≥1 for OR (at least one input is 1), =1 for XOR (exactly one input is 1) and 1 for a buffer or NOT. The drawings here are our own renderings of both. Real gates have more to them than the truth table: delay, voltage levels and how many inputs one output can drive. Gates with more than two inputs follow the same rule: an AND with three inputs gives 1 only when all three are 1. ## FAQ **What is the difference between AND and OR?** AND gives 1 only when all inputs are 1. OR gives 1 when at least one input is 1. **Why are NAND and NOR called universal gates?** Any other gate, and so any digital circuit, can be built from NAND gates alone, or from NOR gates alone. NOT is a NAND with both inputs joined, for example. **What does the small circle on a gate symbol mean?** Inversion: the output (or the input it sits on) is flipped. That is the only difference between the AND and NAND symbols. **What does ≥1 mean in an IEC gate symbol?** That the output is 1 when at least one input is 1: an OR gate. =1 means exactly one input must be 1 (XOR) and & means all of them (AND). **What is XOR used for?** Adding binary digits (the sum bit of an adder), comparing bits, parity checks and simple encryption, since applying the same XOR twice gives back the original. **Which symbol style should I use?** Follow the drawings you work with. IEC boxes are the international standard and common in Europe; the ANSI shapes are common in the United States, in textbooks and in many data sheets. More: [HowToolbox index](https://how.box/llms.txt) · [Agent Skill](https://how.box/skill.md) · [agent terms](https://how.box/about/agents/)