NAND calculator with bit width control
This NAND calculator performs "not AND" on whole numbers: it combines the inputs with AND and then flips every bit of the outcome. Because inversion turns all the unused high bits into 1s, the answer depends on the bit width, so the tool lets you choose 8, 16, 32 or 64 bits.
NAND truth table
| A | B | A AND B | A NAND B |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
The output is 0 only when both inputs are 1.
Worked 8-bit example: 12 NAND 10
00001100 (12)
NAND 00001010 (10)
--------
= 11110111 (247, signed −9, 0xF7)
12 AND 10 is 00001000. Inverting all eight bits gives 11110111, which is 247 as an unsigned byte. The calculator also shows the signed value, −9, because in two's complement a set top bit means the number is negative.
Why the width changes the answer
| Bit width | 12 NAND 10 | Hex |
|---|---|---|
| 8-bit | 247 | 0xF7 |
| 16-bit | 65527 | 0xFFF7 |
| 32-bit | 4294967287 | 0xFFFFFFF7 |
The low bits are identical; only the number of leading 1s changes. The signed reading is −9 in every width, which is a handy way to check your work.
More than two inputs
The calculator takes two operands. A multi-input NAND gate ANDs all inputs and inverts once, so to model one, switch the operation to AND, combine the values two at a time and apply NOT to the last result: 12 AND 10 AND 6 is 0, and NOT 0 is 255 in 8 bits. Note that this differs from chaining two-input NANDs, which gives a different result: 12 NAND 10 is 247, and 247 NAND 6 is 249.
Why NAND matters
NAND is a universal gate: any logic circuit, including NOT, AND, OR and XOR, can be built from NAND gates alone. For example, A NAND A equals NOT A. That is why NAND gates are a staple of digital electronics courses, and NAND flash memory takes its name from the way its cells are wired.
Options
- Input base: decimal, hex, binary or octal, with 0x, 0b and 0o prefixes honored per value.
- Bit width: inputs larger than the width keep only their low bits, and negative inputs are stored in two's complement.
To see the plain AND first, use the AND calculator. For single-value inversion, the NOT calculator is simpler, and the NOR calculator covers the other universal gate.