AND Calculator – Logical & Bitwise AND

Compute logical AND and bitwise AND for up to 4 inputs — see truth tables, bit-by-bit visualization, binary/hex output, and Boolean algebra laws.

AND Result (Decimal)
8
10 AND 12
Result (Binary)
0b00001000
8-bit binary representation
Result (Hex)
0x8
Hexadecimal representation
Input A (Binary)
0b00001010
Decimal: 10 | Hex: 0xA
Input B (Binary)
0b00001100
Decimal: 12 | Hex: 0xC
Bit Width
8-bit
Range: 0 – 255

Bit-by-Bit Visualization

b7
0
0
AND
0
b6
0
0
AND
0
b5
0
0
AND
0
b4
0
0
AND
0
b3
1
1
AND
1
b2
0
1
AND
0
b1
1
0
AND
0
b0
0
0
AND
0
🔵 Input A🟡 Input B🟢 Result

Bit Breakdown Table

Bit PositionABA AND B
Bit 7000
Bit 6000
Bit 5000
Bit 4000
Bit 3111
Bit 2010
Bit 1100
Bit 0000

AND Truth Table Reference

ABA AND B
000
010
100
111

Boolean Algebra Laws (AND)

LawExpression
IdentityA AND 1 = A
NullA AND 0 = 0
IdempotentA AND A = A
ComplementA AND NOT A = 0
CommutativeA AND B = B AND A
Associative(A AND B) AND C = A AND (B AND C)
DistributiveA AND (B OR C) = (A AND B) OR (A AND C)
AbsorptionA AND (A OR B) = A
De MorganNOT(A AND B) = NOT A OR NOT B
Planning notes, formulas, and examples

About the AND Calculator – Logical & Bitwise AND

The AND operation is one of the most fundamental building blocks in logic and computing. In Boolean algebra, AND returns true only when every input is true — making it the logical equivalent of "all conditions must be met." In digital circuits, the AND gate is a basic component that appears in everything from simple combinational logic to complex CPU arithmetic units.

At the bitwise level, AND operates on each corresponding pair of bits in two integers. It is widely used for bit masking — isolating specific bits in a register or flag set. For example, masking an 8-bit value with 0x0F (00001111) extracts the lower nibble by zeroing out the upper four bits, a technique central to low-level programming, networking (subnet masks), and graphics processing.

This calculator handles both logical and bitwise AND for up to four inputs. In bitwise mode you can choose 4-, 8-, 16-, or 32-bit width and see the result in decimal, binary, and hexadecimal along with a colour-coded bit-by-bit visualisation. Preset buttons cover common cases like flag masking and single-bit checks. The truth-table reference and Boolean-algebra-laws table make this a handy study companion for anyone learning digital logic, discrete maths, or embedded programming.

When This Page Helps

Manually ANDing multi-bit numbers means writing out binary columns and comparing each pair — slow and easy to mis-align. This calculator returns results in decimal, binary, and hex, with a colour-coded bit-by-bit breakdown that shows exactly which bits survive. Embedded developers use it to verify bitmask logic, networking students check subnet masks, and CS learners explore Boolean algebra laws without pencil-and-paper drudgery.

How to Use the Inputs

  1. Choose between Bitwise AND and Logical AND mode.
  2. Select the number of inputs (2, 3, or 4).
  3. For bitwise mode, choose a bit width (4, 8, 16, or 32).
  4. Enter integer values for each input.
  5. Click a preset for common examples like 255 AND 15.
  6. Read the result in decimal, binary, and hex in the output cards.
  7. Inspect the bit-by-bit visualisation and breakdown table.
Formula used
Logical AND: T iff all inputs T | Bitwise AND: result bit is 1 iff both input bits are 1

Example Calculation

Result: 8 (0b1000)

AND each bit pair: 1&1=1, 0&1=0, 1&0=0, 0&0=0 → 1000 = 8 in decimal.

Tips & Best Practices

  • Use AND with a mask to isolate specific bits: value & 0x0F keeps only the lower nibble.
  • AND is commutative: A & B = B & A.
  • Chaining AND narrows the result: more inputs can only turn more bits off, never on.
  • In programming, && is logical AND while & is bitwise AND — know the difference.

How Bitwise AND Works at the Hardware Level

At the transistor level, an AND gate outputs high only when both inputs are high. Modern CPUs contain billions of AND gates wired into adders, multiplexers, and control logic. When you write `a & b` in code, the processor lines up the binary representations and feeds each bit pair through an AND gate in parallel — the entire operation completes in a single clock cycle regardless of bit width. This parallelism is what makes bitwise operations so fast compared to multiplication or division.

Common Uses of AND in Programming

The most common use of bitwise AND is **masking**: extracting a subset of bits from a larger value. For example, `color & 0xFF` isolates the lowest 8 bits (the blue channel in a 32-bit ARGB colour). Network engineers AND an IP address with a subnet mask to determine the network prefix: `192.168.1.100 & 255.255.255.0 = 192.168.1.0`. Flags and permissions are stored as packed bits and tested with AND: `if (flags & READ_PERMISSION)` checks a single bit without disturbing the others.

AND in Boolean Algebra and Digital Logic

In formal Boolean algebra, AND corresponds to logical conjunction (∧). Key identities include the **idempotent law** (A ∧ A = A), **identity** (A ∧ 1 = A), **annihilation** (A ∧ 0 = 0), and **De Morgan's theorem** (¬(A ∧ B) = ¬A ∨ ¬B). Digital-logic designers simplify circuits using these identities and Karnaugh maps. AND gates combine with OR, NOT, and XOR gates to build every combinational and sequential circuit, from simple decoders to complete ALUs.

Logical vs Bitwise AND in Code

Most programming languages provide two distinct operators: `&&` (logical AND) and `&` (bitwise AND). Logical AND short-circuits — if the first operand is false, the second is never evaluated. Bitwise AND always evaluates both operands and operates on every bit. Confusing the two is a classic bug: `if (x & 2)` tests a single bit but returns the masked value (which could be 2, not 1). In C-derived languages, use `!= 0` or `!!` to convert a bitwise result to a clean boolean when needed.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • Logical AND evaluates boolean true/false and short-circuits. Bitwise AND operates on each bit position independently and always evaluates both operands.