NOT Calculator

Invert every bit of a number and see the ones complement at the word size you choose.

Value
NOT result
Runs locally in your browser

About the NOT Calculator

NOT is the only bitwise operator that takes a single value. It rewrites each 1 as a 0 and each 0 as a 1, producing what older texts call the ones complement. Unlike AND, OR and XOR, the answer depends entirely on how wide the word is: inverting 12 gives 243 in eight bits but 4294967283 in thirty two, because all the leading zeros flip as well.

That is why the bit width selector matters here more than on the other gate pages. Auto picks the narrowest of 8, 16, 32 or 64 bits that holds your value, which keeps a teaching example short. Pin the width to match the type you are debugging, whether that is a uint8_t register field or a 32-bit mask in C. Every line of input is inverted separately, so a column of register values can be flipped in one paste.

The signed line explains the relationship people usually stumble over: in two’s complement arithmetic NOT x is always equal to -x - 1, which is why inverting 12 in a signed byte reads as -13. Inverting a mask before an AND is the standard way to clear flags, so this page pairs naturally with the AND Calculator. If you want the underlying binary written out instead, the Number Base Converter handles arbitrary bases.

How to use

  1. Type the value to invert, optionally prefixed with 0x or 0b.
  2. Choose a Bit width that matches the variable you are working with.
  3. Read the binary row to confirm every column flipped.
  4. Put several values on separate lines to invert a whole list.

Common questions

Why does NOT 12 give a different answer in 8 and 32 bits?
The leading zeros are part of the word, so a wider word flips more of them. At 8 bits the answer is 243 and at 32 bits it is 4294967283.
Is ones complement the same as twos complement?
No. Ones complement is just the flip; twos complement adds one to that result, which is how negative integers are stored.
How do I clear specific flags?
Invert the mask here, then AND the inverted mask with your value. Only the columns you did not name survive.
Does this handle negative input?
Yes. A negative value is first wrapped into the chosen word using twos complement, then inverted.