Binary Bitwise NAND Calculator
Calculate the bitwise NAND of two binary numbers with step-by-step bit breakdown, truth table, and multi-base output (binary, decimal, hex, octal).
About
The NAND (Not-AND) gate is a universal gate in digital logic. Any Boolean function can be constructed entirely from NAND gates, making it the foundational building block of modern processors and memory circuits. The operation takes two binary operands A and B, computes the bitwise AND, then inverts every bit of the result. A single miscalculated bit in a NAND chain propagates errors through an entire circuit design. This tool performs the operation with full bit-position breakdown so you can verify intermediate AND values before the final inversion, matching what happens at the transistor level.
Inputs are zero-padded to a selectable word size (4, 8, 16, or 32 bits). The tool assumes unsigned integers only. Overflow is handled by truncation to the chosen word size. Results are displayed in binary, decimal, hexadecimal, and octal representations. Pro tip: when debugging combinational logic in HDL or breadboard prototypes, verify your expected NAND outputs here before committing to silicon or FPGA bitstream.
Formulas
The NAND operation is the negation of bitwise AND. For two n-bit unsigned integers A and B:
In two's complement representation with a mask M = 2n − 1, the implementation is:
The mask ensures the result stays within the n-bit word size by zeroing out higher bits that JavaScript's 32-bit signed integer NOT operator would set. For each bit position i from 0 to n − 1:
Where Ai is the bit at position i of operand A, Bi is the bit at position i of operand B, Yi is the resulting bit, n is the word size in bits, and M is the bitmask for the word size.
Reference Data
| A | B | A ∧ B (AND) | ¬(A ∧ B) (NAND) |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
| Gate | Symbol | Boolean Expression | Universality | Transistor Count (CMOS) | Propagation Delay (typ.) |
|---|---|---|---|---|---|
| NAND | ¬(A ⋅ B) | Y = ¬(A ∧ B) | Universal | 4 | 1.2 ns |
| AND | A ⋅ B | Y = A ∧ B | Not universal | 6 | 1.8 ns |
| OR | A + B | Y = A ∨ B | Not universal | 6 | 1.8 ns |
| NOR | ¬(A + B) | Y = ¬(A ∨ B) | Universal | 4 | 1.2 ns |
| NOT | ¬A | Y = ¬A | Not universal | 2 | 0.6 ns |
| XOR | A ⊕ B | Y = A ⊕ B | Not universal | 8 | 2.4 ns |
| XNOR | ¬(A ⊕ B) | Y = ¬(A ⊕ B) | Not universal | 8 | 2.4 ns |
| Buffer | A | Y = A | Not universal | 4 | 1.2 ns |
| NOT via NAND | NAND(A,A) | Y = ¬A | - | 4 | 1.2 ns |
| AND via NAND | NAND(NAND(A,B)) | Y = A ∧ B | - | 8 | 2.4 ns |
| OR via NAND | NAND(NAND(A,A),NAND(B,B)) | Y = A ∨ B | - | 12 | 3.6 ns |