Home Tools Blog About

Bitwise Calculator

In short

This calculator applies AND, OR, XOR, NAND, NOR, XNOR or NOT to binary, hex or decimal numbers and shows every result in all three bases, lined up bit by bit.

  • Runs in your browser
  • Nothing uploaded
  • Free, no sign-up

Values and operation

Operation

Put values on separate lines (commas and semicolons also work). A 0x prefix always means hex and 0b means binary (in Hex mode, 0B12 is read as hex). Spaces and underscores inside a value are ignored, so 1010 1100 is one value.

Result

Enter values and press Calculate (or Ctrl+Enter).

Runs in your browser; what you type is not uploaded.

Truth table for one bit

🛡
Private by designYour files and text stay in this tab
⚡
Runs in your browserNo waiting for a server
💧
No watermarksClean output you can use
🆓
FreeNo account needed

How to Use Bitwise Calculator

  1. Pick the operation: AND, OR, XOR, NAND, NOR, XNOR or NOT.
  2. Choose the input base (binary, hex or decimal) and the bit width.
  3. Enter values one per line, or two lists in line-by-line mode.
  4. Read the result in binary, hex and decimal, then copy the one you need.

Worked example

Take two bytes, 11001010 (hex CA, decimal 202) and 10101100 (hex AC, decimal 172). Line them up and compare each column of bits:

       Binary      Hex    Decimal
A      1100 1010   0xCA   202
B      1010 1100   0xAC   172
AND    1000 1000   0x88   136
OR     1110 1110   0xEE   238
XOR    0110 0110   0x66   102
NAND   0111 0111   0x77   119

With an 8-bit width, NOT of 0x0F gives 0xF0 (240). At 16 bits the same NOT gives 0xFFF0 (65520), because there are eight more leading zeros to flip.

How it works

Each operation looks at one bit position at a time. AND gives 1 only when both bits are 1. OR gives 1 when at least one bit is 1. XOR gives 1 when the bits differ. NAND, NOR and XNOR are AND, OR and XOR with the result flipped. NOT flips every bit of a single value.

Flipping only makes sense inside a fixed number of bits, so the tool builds a mask of width ones and computes NOT x = mask XOR x. With Auto width, the width comes from what you typed: the digit count for binary, 4 bits per hex digit, and the smallest of 8, 16, 32 or 64 bits that fits a decimal number. When you give more than two values in one list, they are combined left to right (A AND B AND C), and the N-versions flip that final result. Numbers are handled as BigInt, so a 200-bit value works the same as a 4-bit one.

What it does not do

  • No bit shifts or rotations (<<, >>), and no arithmetic such as addition.
  • No octal input. Decimal values must be whole numbers.
  • Negative decimals work only with a fixed 8, 16, 32 or 64-bit width, written in two’s complement.
  • A single value can be up to 4096 bits, and a list can hold up to 5000 values.

Frequently asked questions

How does XOR work?

XOR (exclusive or) compares two bits and returns 1 when they are different and 0 when they are the same. So 1100 XOR 1010 = 0110. A useful property: XOR with the same value twice gives back the original, which is why XOR shows up in checksums, simple ciphers and swap tricks.

What is the difference between AND and NAND?

NAND is AND followed by NOT. Where AND gives 1, NAND gives 0, and the other way round. 1100 AND 1010 = 1000, so 1100 NAND 1010 = 0111. NAND matters in hardware because any other logic gate can be built from NAND gates alone.

Why does NOT give a different answer at 8 bits and 32 bits?

NOT flips every bit, including the leading zeros you did not type. 0x0F at 8 bits is 0000 1111, which flips to 1111 0000 (0xF0). At 32 bits there are 24 more zeros in front, so the result is 0xFFFFFFF0. Pick the width your data type uses: 8 for a byte, 32 for a C int, 64 for a long.

How do I use negative numbers?

Choose Decimal as the base and a fixed width, then type the number with a minus sign. The tool stores it in two’s complement, so -1 at 8 bits is 1111 1111 (0xFF). With a fixed width the table also shows a Signed column, which reads the result back as a signed number.

Can I combine more than two values, or many pairs at once?

Yes. In “All together” mode, every value in the list is combined into one result, for example A AND B AND C. In “Line by line” mode, line 1 of list A is combined with line 1 of list B, line 2 with line 2, and so on. If one list has a single value, it is applied to every line of the other list, which is handy for masking many values with one mask.

Keep going

Related Tools

All Binary tools →
Share

Embed this tool

Add this free tool to your website. Copy and paste the code: