Overview
Enter two integers and calculate their bitwise NAND - NOT(A AND B) - the operation that's functionally complete in digital logic, meaning any other logic gate (AND, OR, NOT, XOR, and more) can be built from NAND gates alone. Because the NOT step needs a fixed number of bits to produce a meaningful, non-negative result, this calculator requires you to choose an explicit bit width - 8, 16, or 32 bits - rather than relying on JavaScript's unbounded integer or 32-bit-signed bitwise defaults. Each input accepts decimal, 0b-prefixed binary, or 0x-prefixed hex, and the result is shown in all three formats, zero-padded to match the selected width. Both inputs are validated against the chosen width, so a value that doesn't fit (like 300 at 8-bit) is caught with a specific error. Runs entirely client-side.
Best for: Verifying a NAND gate truth-table value or a logic-simulation result by hand
How to use this tool
- Choose a bit width. 8, 16, or 32 bits - this determines how the NOT step is bounded.
- Enter A and B. Decimal, 0b-prefixed binary, or 0x-prefixed hex, each validated against the chosen width.
- Read the NAND result. NOT(A AND B), shown in decimal, zero-padded binary, and hex all at once.
Frequently asked questions
NOT flips every bit of a value, and without a fixed width that produces either an unbounded result or, using JavaScript's native 32-bit signed bitwise operators, a negative number that doesn't match how NAND is normally taught or used in digital logic. Choosing 8, 16, or 32 bits fixes exactly how many bits get flipped, so the result is a bounded, non-negative value consistent with how a real NAND gate or logic simulator would represent it at that width.
It's rejected with a specific error message naming the valid range - for example, at 8-bit width, only values from 0 to 255 are accepted, so entering 300 would be flagged rather than silently truncated or wrapped.
Any Boolean logic function - AND, OR, NOT, XOR, and every other gate - can be constructed using only NAND gates, which is why NAND (and its counterpart NOR) are common building blocks in real digital circuits: a chip designer can implement an entire logic system from a single gate type.