How to use the Bitwise NAND Calculator tool
- Enter a binary value such as 1100 in Input A.
- Enter the other operand, such as 1010, in Input B.
- Select Calculate to see the NAND of the two values.
- Check the Result box. For 1100 and 1010 it shows 0111.
- Use Copy to take the result to your clipboard, or Example to reload the sample values.
What bitwise NAND computes
NAND stands for NOT AND. For each bit position the tool first works out A AND B, then flips the answer. The result bit is 0 only when both input bits are 1, and 1 in the other three cases.
By De Morgan's law the same result can be written as (NOT A) OR (NOT B). Both forms describe one operation: a column produces 1 as soon as either input bit is 0.
A B | A NAND B
0 0 | 1
0 1 | 1
1 0 | 1
1 1 | 0Why the word size matters for NAND
Inverting needs a fixed width, because a number has unlimited implied zeros on its left and all of them would turn into ones. This calculator uses the longer of the two inputs as the word size. The shorter input is padded on the left with zeros, the AND is taken, and the inversion is limited to that many bits.
Leading zeros you type are therefore significant. 1 NAND 1 is 0, yet 0001 NAND 0001 is 1110, since the three upper positions hold 0 AND 0 and invert to 1. When one input is shorter, the padded positions always come out as 1: 101 NAND 11111 gives 11010.
Worked NAND example
Take 1011 and 1101. The AND is 1001, since only the first and last columns contain two ones. Inverting those four bits gives 0110.
1011 (Input A)
NAND 1101 (Input B)
AND 1001
NAND 0110NAND as a universal gate
NAND is functionally complete: any Boolean function can be built from NAND alone. That property makes the NAND gate a basic cell in CMOS chip design. NAND flash memory takes its name from the way its cells are wired in series, like the transistors of a NAND gate.
You can reproduce the standard constructions with this calculator, one gate at a time.
- NOT A is A NAND A. Enter 1100 in both fields and the result is 0011.
- A AND B is A NAND B, fed into a second NAND with itself.
- A OR B is (A NAND A) NAND (B NAND B). For 1100 and 1010 that is 0011 NAND 0101, which gives 1110.
Frequently asked questions
What is 1100 NAND 1010?
It is 0111. The AND of the two values is 1000, and inverting those four bits gives 0111. Only the leftmost column has a 1 in both inputs, so it is the only 0 in the result.
How do I calculate NAND in C, Python or JavaScript?
Combine the AND and NOT operators: ~(a & b). To get an unsigned result of a fixed width, mask it, for example ~(a & b) & 0xFF for 8 bits. This calculator applies that kind of mask using the longer input's length.
Why does my NAND result start with ones I did not expect?
The shorter input was padded with zeros, or both inputs had leading zeros. A column holding two zeros gives 0 for AND and 1 after inversion. Trim leading zeros from both inputs if you want a narrower word.
Is NAND the same as inverting each input and then using AND?
No. Inverting the inputs first and then ANDing them is NOR. NAND inverts after the AND, which equals (NOT A) OR (NOT B). For 1100 and 1010, NAND gives 0111 while NOR gives 0001.
What input does the NAND calculator accept?
Each field takes 1 to 65,536 binary digits. Spaces are ignored and an optional 0b prefix is removed. Decimal digits, hex digits or an empty field produce an error message instead of a result.
How does this differ from the NAND Gate Simulator?
The NAND Gate Simulator evaluates a single pair of bits chosen from 0 and 1. This calculator applies the same gate to every column of two multi-bit words in one pass and returns a word of the same width.