FormatterHQ

NAND Calculator

Compute the bitwise NAND of two numbers: an AND whose result is inverted. Results appear in four bases, with a signed reading and a bit grid.

Loading tool…
Ready.

How to use the NAND Calculator

  1. Type two whole numbers in Operand A and Operand B.
  2. Pick the base of each operand and the bit width (8-bit is the default).
  3. Read the NAND result in decimal, signed decimal, hex, octal and binary.
  4. Copy the value or compare it with the bit grid.

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

ABA AND BA NAND B
0001
0101
1001
1110

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 width12 NAND 10Hex
8-bit2470xF7
16-bit655270xFFF7
32-bit42949672870xFFFFFFF7

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.

Frequently asked questions

What is 12 NAND 10?
In 8 bits it is 247 (binary 11110111, hex F7), which is −9 when read as a signed byte. In 16 bits it is 65527 and in 32 bits 4294967287; the low bits are the same in every case.
How do I write NAND in code?
Most languages have no NAND operator, so combine NOT and AND: ~(a & b). In languages with unlimited integers, such as Python, add a mask for your width, for example ~(a & b) & 0xFF for 8 bits.
Why is NAND called a universal gate?
Every other logic function can be built from NAND alone. NOT A is A NAND A, AND is NOT of NAND, and OR can be made as (A NAND A) NAND (B NAND B).
Why does the result show a negative signed value?
NAND sets the high bits whenever the inputs are small, and in two's complement a set top bit means a negative number. The unsigned decimal is shown first; the signed line appears only when the two readings differ.

Last updated October 3, 2026

Related tools