AND: The Logical Conjunction
In logic, AND does the same job as the word and in grammar. It joins two or more elements and asserts that they are all true at the same moment, in the same space, or in the same situation.
AND is a logical operator: it resembles an arithmetic operator, but it works only on a restricted set of values:
- True, or
1; - False, or
0.
The logical AND operator returns true only if every input operand is true. A single false input drives the result to false, no matter how many other inputs are true.
How AND Is Written
Considering two operands (A, B), you will meet the AND operator written in many ways:
| Context | Notation |
|---|---|
| Verbose (natural language) | A AND B |
| Mathematics | A ∧ B |
| Electronics | A · B (a centred dot — the product) |
| Programming languages | A & B, A && B, or A and B |
| Łukasiewicz (Polish) notation | Kab — a prefix operator |
The electronics notation is the most revealing one: AND really is a product. That single idea explains everything else on this page.
How to Calculate the AND in Binary
Logic operations share many similarities with binary arithmetic. Computing the AND of two binary numbers is exactly a bitwise product — multiply the digits in matching positions, one column at a time. Each bit is either 1 or 0, so there are only four cases:
0 × 0 = 00 × 1 = 01 × 0 = 01 × 1 = 1
Only the last one returns something other than 0.
Example: 10101 AND 11001
- Stack the numbers one over the other, aligned to the right.
- Take the pairs of bits in the same position.
- Multiply them.
- Build the result progressively.
10101 ∧ 11001 = ----- 10001
Start with the rightmost pair, 1 and 1: the result is 1 × 1 = 1. Next, 0 and 0: that is 0 × 0 = 0. The third position is the first mixed case, 1 × 0 = 0, and so on. The result is 10001 — that is 21 AND 25 = 17 in decimal.
You can calculate AND for any number of operands: just keep adding factors to the product. Notice how all it takes is for one of them to be 0 to make the entire product collapse to 0. This calculator accepts up to eight operands so you can watch that collapse happen.
The Truth Table of the AND Logic Gate
The truth table defines the output for every possible pair of single-bit inputs:
| A | B | A ∧ B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Three rows out of four return 0. AND is a demanding operator: it agrees only when everyone agrees.
The Logic AND Gate
In digital electronics, the AND gate outputs HIGH (1) only when all of its inputs are HIGH. It is drawn with a flat back and a rounded (D-shaped) front. Because AND is a product, an AND gate is the natural "carry" partner of the XOR gate in a half-adder circuit.
AND is closely tied to the other gates:
- NAND is simply
NOT(A AND B)— an AND gate with an inverted output. NAND is functionally complete: every other gate can be built from NANDs alone. - De Morgan's law rebuilds AND out of OR and NOT:
A ∧ B = NOT(NOT A OR NOT B). Your results panel checks this identity against your own numbers on every calculation.
Useful Properties of AND
- Idempotent:
A ∧ A = A. ANDing a value with itself changes nothing. - Absorbing element:
A ∧ 0 = 0. A single zero factor annihilates the product. - Identity element:
A ∧ 111…1 = A. ANDing with an all-ones mask leaves the value untouched. - Commutative and associative:
A ∧ B = B ∧ Aand(A ∧ B) ∧ C = A ∧ (B ∧ C), which is why an operand list can be folded in any order. - It can only clear bits, never set them. Therefore
A ∧ B ≤ min(A, B), and the result is always a submask of every operand. - Submask test: if
A ∧ B = A, then every bit of A is present in B — A is a subset of B, and in logic A implies B.
How to Use Our AND Calculator
- Select the Input Format: Decimal (base 10), Binary (base 2), Octal (base 8), or Hexadecimal (base 16).
- Choose the Number of Operands, from 2 up to 8.
- Enter each operand as a non-negative integer in the chosen format.
- Optionally, value the shared bits: read every bit position as an item, then give each shared item a price (20 world currencies), a metric amount, or a US customary amount. The calculator converts between the metric and US systems for you.
- Click Calculate AND.
- The results panel shows the AND in decimal, binary, octal and hexadecimal, a bit-by-bit product table for widths up to 32 bits, and a read-out of what the result tells you about your operands.
Where AND Is Used
- Bit masking —
value & 0x0Fkeeps only the bits you care about and clears the rest. This is the single most common use of AND in programming. - Subnetting — an IP address ANDed with its subnet mask yields the network address.
- Permission and feature flags — ANDing two bitmasks returns exactly the permissions that both parties hold, i.e. the intersection of two sets.
- Testing a single bit —
value & (1 << n)is non-zero only when bit n is set. - Testing parity or divisibility by powers of two —
n & 1tells you whether n is odd;n & (n - 1)clears the lowest set bit, so for anyn > 0it equals 0 exactly when n is a power of two. - Carry generation — in a half-adder, AND produces the carry while XOR produces the sum.
- Conditional logic —
if (a && b)executes only when both conditions hold.
Frequently Asked Questions (FAQ)
Is AND the same as multiplication?
For single bits, yes — that is exactly why electronics writes it as A · B. For whole numbers it is a bitwise product: each column is multiplied independently, with no carries between columns. So 3 AND 3 = 3, while 3 × 3 = 9.
What is AND of a number with itself?
A ∧ A = A for any integer A, because every bit is multiplied by itself and 1 × 1 = 1, 0 × 0 = 0. This is called idempotence.
What is AND of a number with zero?
A ∧ 0 = 0 for any A. Zero is the absorbing element: one zero factor collapses the whole product, which is the defining behaviour of AND.
Can the AND result be larger than its operands?
Never. AND can only turn 1s into 0s, so the result is always less than or equal to the smallest operand, and its set bits are always a subset of every operand's set bits.
How is AND different from OR and XOR?
AND returns 1 only when every input is 1. OR returns 1 when at least one input is 1. XOR returns 1 when the inputs differ. For inputs 1 and 1: AND gives 1, OR gives 1, and XOR gives 0.
Is AND commutative and associative?
Yes to both, which is why this calculator can fold any number of operands in a single pass and why the order you type them in does not matter.
Can AND be used with negative numbers?
On real processors AND operates on the two's-complement bit pattern, so it works with negative values too. This calculator accepts non-negative integers only; for signed operands the result depends on the chosen bit width.